移除重复的事件绑定
This commit is contained in:
parent
4cd9b66653
commit
a9b04312d8
@ -28,7 +28,6 @@ class Event extends EventEmitter {
|
|||||||
// 绑定函数上下文
|
// 绑定函数上下文
|
||||||
bindFn() {
|
bindFn() {
|
||||||
this.onDrawClick = this.onDrawClick.bind(this)
|
this.onDrawClick = this.onDrawClick.bind(this)
|
||||||
this.onDrawMousedown = this.onDrawMousedown.bind(this)
|
|
||||||
this.onMousedown = this.onMousedown.bind(this)
|
this.onMousedown = this.onMousedown.bind(this)
|
||||||
this.onMousemove = this.onMousemove.bind(this)
|
this.onMousemove = this.onMousemove.bind(this)
|
||||||
this.onMouseup = this.onMouseup.bind(this)
|
this.onMouseup = this.onMouseup.bind(this)
|
||||||
@ -41,7 +40,6 @@ class Event extends EventEmitter {
|
|||||||
// 绑定事件
|
// 绑定事件
|
||||||
bind() {
|
bind() {
|
||||||
this.mindMap.svg.on('click', this.onDrawClick)
|
this.mindMap.svg.on('click', this.onDrawClick)
|
||||||
this.mindMap.svg.on('mousedown', this.onDrawMousedown)
|
|
||||||
this.mindMap.el.addEventListener('mousedown', this.onMousedown)
|
this.mindMap.el.addEventListener('mousedown', this.onMousedown)
|
||||||
this.mindMap.svg.on('mousedown', this.onSvgMousedown)
|
this.mindMap.svg.on('mousedown', this.onSvgMousedown)
|
||||||
window.addEventListener('mousemove', this.onMousemove)
|
window.addEventListener('mousemove', this.onMousemove)
|
||||||
@ -54,7 +52,6 @@ class Event extends EventEmitter {
|
|||||||
// 解绑事件
|
// 解绑事件
|
||||||
unbind() {
|
unbind() {
|
||||||
this.mindMap.svg.off('click', this.onDrawClick)
|
this.mindMap.svg.off('click', this.onDrawClick)
|
||||||
this.mindMap.svg.off('mousedown', this.onDrawMousedown)
|
|
||||||
this.mindMap.el.removeEventListener('mousedown', this.onMousedown)
|
this.mindMap.el.removeEventListener('mousedown', this.onMousedown)
|
||||||
window.removeEventListener('mousemove', this.onMousemove)
|
window.removeEventListener('mousemove', this.onMousemove)
|
||||||
window.removeEventListener('mouseup', this.onMouseup)
|
window.removeEventListener('mouseup', this.onMouseup)
|
||||||
@ -68,11 +65,6 @@ class Event extends EventEmitter {
|
|||||||
this.emit('draw_click', e)
|
this.emit('draw_click', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 画布的鼠标按下事件
|
|
||||||
onDrawMousedown(e) {
|
|
||||||
this.emit('draw_mousedown', e)
|
|
||||||
}
|
|
||||||
|
|
||||||
// svg画布的鼠标按下事件
|
// svg画布的鼠标按下事件
|
||||||
onSvgMousedown(e) {
|
onSvgMousedown(e) {
|
||||||
this.emit('svg_mousedown', e)
|
this.emit('svg_mousedown', e)
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export default class TextEdit {
|
|||||||
// 隐藏文本编辑框
|
// 隐藏文本编辑框
|
||||||
this.hideEditTextBox()
|
this.hideEditTextBox()
|
||||||
})
|
})
|
||||||
this.mindMap.on('draw_mousedown', () => {
|
this.mindMap.on('svg_mousedown', () => {
|
||||||
// 隐藏文本编辑框
|
// 隐藏文本编辑框
|
||||||
this.hideEditTextBox()
|
this.hideEditTextBox()
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user