移除重复的事件绑定

This commit is contained in:
wanglin2 2023-03-31 22:30:06 +08:00
parent 4cd9b66653
commit a9b04312d8
2 changed files with 1 additions and 9 deletions

View File

@ -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)

View File

@ -23,7 +23,7 @@ export default class TextEdit {
// 隐藏文本编辑框
this.hideEditTextBox()
})
this.mindMap.on('draw_mousedown', () => {
this.mindMap.on('svg_mousedown', () => {
// 隐藏文本编辑框
this.hideEditTextBox()
})