From a161661c6bf8d00547490a9bff3eaf708b425692 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Mon, 17 Jul 2023 09:07:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=8A=82=E7=82=B9=E8=BF=87?= =?UTF-8?q?=E6=B8=A1=E5=8A=A8=E7=94=BB=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/package.json | 2 +- .../src/constants/defaultOptions.js | 4 ---- simple-mind-map/src/core/render/Render.js | 15 +------------- simple-mind-map/src/core/render/node/Node.js | 20 ++----------------- web/src/pages/Doc/en/constructor/index.md | 4 ++-- web/src/pages/Doc/en/constructor/index.vue | 4 ++-- web/src/pages/Doc/zh/constructor/index.md | 4 ++-- web/src/pages/Doc/zh/constructor/index.vue | 4 ++-- 8 files changed, 12 insertions(+), 45 deletions(-) diff --git a/simple-mind-map/package.json b/simple-mind-map/package.json index 8939adc3..18640db9 100644 --- a/simple-mind-map/package.json +++ b/simple-mind-map/package.json @@ -1,6 +1,6 @@ { "name": "simple-mind-map", - "version": "0.6.6", + "version": "0.6.7", "description": "一个简单的web在线思维导图", "authors": [ { diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 26abae16..a89f448d 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -79,10 +79,6 @@ export const defaultOpt = { }, // 是否只有当鼠标在画布内才响应快捷键事件 enableShortcutOnlyWhenMouseInSvg: true, - // 是否开启节点动画过渡 - enableNodeTransitionMove: true, - // 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms - nodeTransitionMoveDuration: 300, // 初始根节点的位置 initRootNodePosition: null, // 导出png、svg、pdf时的图形内边距 diff --git a/simple-mind-map/src/core/render/Render.js b/simple-mind-map/src/core/render/Render.js index 708b689f..6493a515 100644 --- a/simple-mind-map/src/core/render/Render.js +++ b/simple-mind-map/src/core/render/Render.js @@ -259,7 +259,6 @@ class Render { // 渲染 render(callback = () => {}, source) { - let t = Date.now() // 如果当前还没有渲染完毕,不再触发渲染 if (this.isRendering) { // 等待当前渲染完毕后再进行一次渲染 @@ -290,7 +289,7 @@ class Render { // 更新根节点 this.root = root // 渲染节点 - const onEnd = () => { + this.root.render(() => { this.isRendering = false this.mindMap.emit('node_tree_render_end') callback && callback() @@ -303,18 +302,6 @@ class Render { this.mindMap.command.addHistory() } } - } - let { enableNodeTransitionMove, nodeTransitionMoveDuration } = - this.mindMap.opt - this.root.render(() => { - let dur = Date.now() - t - if (enableNodeTransitionMove && dur <= nodeTransitionMoveDuration) { - setTimeout(() => { - onEnd() - }, nodeTransitionMoveDuration - dur); - } else { - onEnd() - } }) }) this.mindMap.emit('node_active', null, this.activeNodeList) diff --git a/simple-mind-map/src/core/render/node/Node.js b/simple-mind-map/src/core/render/node/Node.js index e0f36761..e9724f41 100644 --- a/simple-mind-map/src/core/render/node/Node.js +++ b/simple-mind-map/src/core/render/node/Node.js @@ -476,8 +476,6 @@ class Node { return } let { - enableNodeTransitionMove, - nodeTransitionMoveDuration, alwaysShowExpandBtn } = this.mindMap.opt if (alwaysShowExpandBtn) { @@ -503,13 +501,7 @@ class Node { let t = this.group.transform() // 如果节点位置没有变化,则返回 if (this.left === t.translateX && this.top === t.translateY) return - if (!isLayout && enableNodeTransitionMove) { - this.group - .animate(nodeTransitionMoveDuration) - .translate(this.left - t.translateX, this.top - t.translateY) - } else { - this.group.translate(this.left - t.translateX, this.top - t.translateY) - } + this.group.translate(this.left - t.translateX, this.top - t.translateY) } // 重新渲染节点,即重新创建节点内容、计算节点大小、计算节点内容布局、更新展开收起按钮,概要及位置 @@ -531,8 +523,6 @@ class Node { // 递归渲染 render(callback = () => {}) { - let { enableNodeTransitionMove, nodeTransitionMoveDuration } = - this.mindMap.opt // 节点 // 重新渲染连线 this.renderLine() @@ -580,13 +570,7 @@ class Node { }) ) } else { - if (enableNodeTransitionMove && !isLayout) { - setTimeout(() => { - callback() - }, nodeTransitionMoveDuration) - } else { - callback() - } + callback() } // 手动插入的节点立即获得焦点并且开启编辑模式 if (this.nodeData.inserting) { diff --git a/web/src/pages/Doc/en/constructor/index.md b/web/src/pages/Doc/en/constructor/index.md index aee2e43b..ca77b9fa 100644 --- a/web/src/pages/Doc/en/constructor/index.md +++ b/web/src/pages/Doc/en/constructor/index.md @@ -51,8 +51,8 @@ const mindMap = new MindMap({ | expandBtnStyle(v0.5.0+) | Object | { color: '#808080', fill: '#fff' } | Expand the color of the stow button | | | expandBtnIcon(v0.5.0+) | Object | { open: '', close: '' } | Customize the icon of the expand/collapse button, and you can transfer the svg string of the icon | | | enableShortcutOnlyWhenMouseInSvg(v0.5.1+) | Boolean | true | Only respond to shortcut key events when the mouse is inside the canvas | | -| enableNodeTransitionMove(v0.5.1+) | Boolean | true | Whether to enable node animation transition | | -| nodeTransitionMoveDuration(v0.5.1+) | Number | 300 | If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds | | +| enableNodeTransitionMove(v0.5.1+)(v0.6.7+ is remove this feature) | Boolean | true | Whether to enable node animation transition | | +| nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+ is remove this feature) | Number | 300 | If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds | | | initRootNodePosition(v0.5.3+) | Array | null | The position of the initial root node can be passed as an array, default is `['center', 'center']`, Represents the root node at the center of the canvas, In addition to `center`, keywords can also be set to `left`, `top`, `right`, and `bottom`, In addition to passing keywords, each item in the array can also pass a number representing a specific pixel, Can pass a percentage string, such as `['40%', '60%']`, Represents a horizontal position at `40%` of the canvas width, and a vertical position at `60%` of the canvas height | | | exportPaddingX(v0.5.5+) | Number | 10 | Horizontal padding of graphics when exporting PNG, SVG, and PDF | | | exportPaddingY(v0.5.5+) | Number | 10 | Vertical padding of graphics when exporting PNG, SVG, and PDF | | diff --git a/web/src/pages/Doc/en/constructor/index.vue b/web/src/pages/Doc/en/constructor/index.vue index c824c0ef..f32936c4 100644 --- a/web/src/pages/Doc/en/constructor/index.vue +++ b/web/src/pages/Doc/en/constructor/index.vue @@ -218,14 +218,14 @@ -enableNodeTransitionMove(v0.5.1+) +enableNodeTransitionMove(v0.5.1+)(v0.6.7+ is remove this feature) Boolean true Whether to enable node animation transition -nodeTransitionMoveDuration(v0.5.1+) +nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+ is remove this feature) Number 300 If node animation transition is enabled, the transition time can be set using this attribute, in milliseconds diff --git a/web/src/pages/Doc/zh/constructor/index.md b/web/src/pages/Doc/zh/constructor/index.md index 8d9e7b1b..c1775920 100644 --- a/web/src/pages/Doc/zh/constructor/index.md +++ b/web/src/pages/Doc/zh/constructor/index.md @@ -51,8 +51,8 @@ const mindMap = new MindMap({ | expandBtnStyle(v0.5.0+) | Object | { color: '#808080', fill: '#fff' } | 展开收起按钮的颜色 | | | expandBtnIcon(v0.5.0+) | Object | { open: '', close: '' } | 自定义展开收起按钮的图标,可以传图标的svg字符串 | | | enableShortcutOnlyWhenMouseInSvg(v0.5.1+) | Boolean | true | 是否只有当鼠标在画布内才响应快捷键事件 | | -| enableNodeTransitionMove(v0.5.1+) | Boolean | true | 是否开启节点动画过渡 | | -| nodeTransitionMoveDuration(v0.5.1+) | Number | 300 | 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms | | +| enableNodeTransitionMove(v0.5.1+)(v0.6.7+已去除该特性) | Boolean | true | 是否开启节点动画过渡 | | +| nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+已去除该特性) | Number | 300 | 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms | | | initRootNodePosition(v0.5.3+) | Array | null | 初始根节点的位置,可传一个数组,默认为`['center', 'center']`,代表根节点处于画布中心位置,除了`center`,关键词还可以设置`left`、`top`、`right`、`bottom`,除了可以传关键词,数组的每项还可以传递一个数字,代表具体的像素,可以传递一个百分比字符串,比如`['40%', '60%']`,代表水平位置在画布宽度的`40%`的位置,垂直位置在画布高度的`60%`的位置 | | | exportPaddingX(v0.5.5+) | Number | 10 | 导出png、svg、pdf时的图形水平内边距 | | | exportPaddingY(v0.5.5+) | Number | 10 | 导出png、svg、pdf时的图形垂直内边距 | | diff --git a/web/src/pages/Doc/zh/constructor/index.vue b/web/src/pages/Doc/zh/constructor/index.vue index 47cd694f..dd36b5eb 100644 --- a/web/src/pages/Doc/zh/constructor/index.vue +++ b/web/src/pages/Doc/zh/constructor/index.vue @@ -218,14 +218,14 @@ -enableNodeTransitionMove(v0.5.1+) +enableNodeTransitionMove(v0.5.1+)(v0.6.7+已去除该特性) Boolean true 是否开启节点动画过渡 -nodeTransitionMoveDuration(v0.5.1+) +nodeTransitionMoveDuration(v0.5.1+)(v0.6.7+已去除该特性) Number 300 如果开启节点动画过渡,可以通过该属性设置过渡的时间,单位ms