Skip to content

Commit

Permalink
fix bug where events were bound to wrong object
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancahill committed Nov 25, 2015
1 parent 614c058 commit f1bf2cd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions split.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit f1bf2cd

Please sign in to comment.