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