Skip to content
This repository was archived by the owner on Dec 26, 2018. It is now read-only.

Commit f996571

Browse files
committed
fix handler teardown
1 parent 156ff01 commit f996571

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

vue-touch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,20 @@
8888
mc.off(event, this.handler)
8989
}
9090
if (typeof fn !== 'function') {
91+
this.handler = null
9192
console.warn(
9293
'[vue-touch] invalid handler function for v-touch: ' +
9394
this.arg + '="' + this.descriptor.raw
9495
)
9596
} else {
96-
mc.on(event, fn)
97+
mc.on(event, (this.handler = fn))
9798
}
9899
},
99100

100101
unbind: function () {
101-
this.mc.off(this.arg, this.handler)
102+
if (this.handler) {
103+
this.mc.off(this.arg, this.handler)
104+
}
102105
if (!Object.keys(this.mc.handlers).length) {
103106
this.mc.destroy()
104107
this.el.hammer = null

0 commit comments

Comments
 (0)