Feature:1.优化关联线创建,2.支持按住ctrl键多选和取消多选节点
This commit is contained in:
parent
6ecb97e4e5
commit
5ae8ebe590
4
simple-mind-map/package-lock.json
generated
4
simple-mind-map/package-lock.json
generated
@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "simple-mind-map",
|
"name": "simple-mind-map",
|
||||||
"version": "0.4.4",
|
"version": "0.4.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "0.4.4",
|
"version": "0.4.5",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@svgdotjs/svg.js": "^3.0.16",
|
"@svgdotjs/svg.js": "^3.0.16",
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { walk, bfsWalk } from './utils/'
|
import { walk, bfsWalk, throttle } from './utils/'
|
||||||
import { v4 as uuid } from 'uuid'
|
import { v4 as uuid } from 'uuid'
|
||||||
|
|
||||||
// 关联线类
|
// 关联线类
|
||||||
@ -20,6 +20,8 @@ class AssociativeLine {
|
|||||||
// 箭头图标
|
// 箭头图标
|
||||||
this.markerPath = null
|
this.markerPath = null
|
||||||
this.marker = this.createMarker()
|
this.marker = this.createMarker()
|
||||||
|
// 节流一下,不然很卡
|
||||||
|
this.checkOverlapNode = throttle(this.checkOverlapNode, 100, this)
|
||||||
this.bindEvent()
|
this.bindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -675,6 +675,17 @@ class Node {
|
|||||||
if (!this.isRoot) {
|
if (!this.isRoot) {
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
}
|
||||||
|
// 多选和取消多选
|
||||||
|
if (e.ctrlKey) {
|
||||||
|
let isActive = this.nodeData.data.isActive
|
||||||
|
this.mindMap.renderer.setNodeActive(this, !isActive)
|
||||||
|
this.mindMap.renderer[isActive ? 'removeActiveNode' : 'addActiveNode'](this)
|
||||||
|
this.mindMap.emit(
|
||||||
|
'node_active',
|
||||||
|
isActive ? null : this,
|
||||||
|
this.mindMap.renderer.activeNodeList
|
||||||
|
)
|
||||||
|
}
|
||||||
this.mindMap.emit('node_mousedown', this, e)
|
this.mindMap.emit('node_mousedown', this, e)
|
||||||
})
|
})
|
||||||
this.group.on('mouseup', e => {
|
this.group.on('mouseup', e => {
|
||||||
@ -699,7 +710,8 @@ class Node {
|
|||||||
})
|
})
|
||||||
// 右键菜单事件
|
// 右键菜单事件
|
||||||
this.group.on('contextmenu', e => {
|
this.group.on('contextmenu', e => {
|
||||||
if (this.mindMap.opt.readonly || this.isGeneralization) {
|
// 按住ctrl键点击鼠标左键不知为何触发的是contextmenu事件
|
||||||
|
if (this.mindMap.opt.readonly || this.isGeneralization || e.ctrlKey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
|
|||||||
@ -195,12 +195,12 @@ export const downloadFile = (file, fileName) => {
|
|||||||
// 节流函数
|
// 节流函数
|
||||||
export const throttle = (fn, time = 300, ctx) => {
|
export const throttle = (fn, time = 300, ctx) => {
|
||||||
let timer = null
|
let timer = null
|
||||||
return () => {
|
return (...args) => {
|
||||||
if (timer) {
|
if (timer) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
timer = setTimeout(() => {
|
timer = setTimeout(() => {
|
||||||
fn.call(ctx)
|
fn.call(ctx, ...args)
|
||||||
timer = null
|
timer = null
|
||||||
}, time)
|
}, time)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user