From f1bf2cd8a59cad128407057030d7a658d2e54d94 Mon Sep 17 00:00:00 2001 From: Nathan Cahill Date: Wed, 25 Nov 2015 12:43:24 -0800 Subject: [PATCH] fix bug where events were bound to wrong object --- split.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/split.js b/split.js index d959745f..d89b16db 100644 --- a/split.js +++ b/split.js @@ -75,12 +75,16 @@ var global = this e.preventDefault() this.dragging = true - this.stop = stopDragging.bind(pair) + this.move = drag.bind(this) + this.stop = stopDragging.bind(this) global[addEventListener]('mouseup', this.stop) global[addEventListener]('touchend', this.stop) global[addEventListener]('touchcancel', this.stop) + this.parent[addEventListener]('mousemove', this.move) + this.parent[addEventListener]('touchmove', this.move) + this.a[addEventListener]('selectstart', preventSelection) this.a[addEventListener]('dragstart', preventSelection) this.b[addEventListener]('selectstart', preventSelection) @@ -113,7 +117,11 @@ var global = this global[removeEventListener]('touchend', this.stop) global[removeEventListener]('touchcancel', this.stop) + this.parent[removeEventListener]('mousemove', this.move) + this.parent[removeEventListener]('touchmove', this.move) + delete this.stop + delete this.move this.a[removeEventListener]('selectstart', preventSelection) this.a[removeEventListener]('dragstart', preventSelection) @@ -274,10 +282,7 @@ var global = this gutter.style[dimension] = options.gutterSize + 'px' gutter[addEventListener]('mousedown', startDragging.bind(pair)) - parent[addEventListener]('mousemove', drag.bind(pair)) - gutter[addEventListener]('touchstart', startDragging.bind(pair)) - parent[addEventListener]('touchmove', drag.bind(pair)) parent.insertBefore(gutter, el)