From bef732ac2694d8ebec4113c102e9fc60742cdaee Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 22 Sep 2012 04:00:30 +0200 Subject: [PATCH] return asap --- 4chan_x.user.js | 17 ++++++++++------- script.coffee | 17 +++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index f79f979dd..c235e49fa 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -254,7 +254,8 @@ height: screenHeight - rect.height, width: screenWidth - rect.width, screenHeight: screenHeight, - screenWidth: screenWidth + screenWidth: screenWidth, + isTouching: isTouching }; if (isTouching) { o.identifier = e.identifier; @@ -277,6 +278,7 @@ touch = _ref[_i]; if (touch.identifier === this.identifier) { drag.call(this, touch); + return; } } }; @@ -315,18 +317,19 @@ for (_i = 0, _len = _ref.length; _i < _len; _i++) { touch = _ref[_i]; if (touch.identifier === this.identifier) { - dragend.call(this, touch); + dragend.call(this); + return; } } }; - dragend = function(e) { - if (e.type === 'mouseup') { - d.removeEventListener('mousemove', this.move, false); - d.removeEventListener('mouseup', this.up, false); - } else { + dragend = function() { + if (this.isTouching) { d.removeEventListener('touchmove', this.move, false); d.removeEventListener('touchend', this.up, false); d.removeEventListener('touchcancel', this.up, false); + } else { + d.removeEventListener('mousemove', this.move, false); + d.removeEventListener('mouseup', this.up, false); } return localStorage.setItem("" + g.NAMESPACE + this.id + ".position", this.style.cssText); }; diff --git a/script.coffee b/script.coffee index a3e8164ee..f6c34b33d 100644 --- a/script.coffee +++ b/script.coffee @@ -206,6 +206,7 @@ UI = (-> width: screenWidth - rect.width screenHeight: screenHeight screenWidth: screenWidth + isTouching: isTouching } if isTouching o.identifier = e.identifier @@ -223,7 +224,7 @@ UI = (-> for touch in e.changedTouches if touch.identifier is @identifier drag.call @, touch - return + return drag = (e) -> left = e.clientX - @dx top = e.clientY - @dy @@ -246,16 +247,16 @@ UI = (-> touchend = (e) -> for touch in e.changedTouches if touch.identifier is @identifier - dragend.call @, touch - return - dragend = (e) -> - if e.type is 'mouseup' - d.removeEventListener 'mousemove', @move, false - d.removeEventListener 'mouseup', @up, false - else # touchend or touchcancel + dragend.call @ + return + dragend = -> + if @isTouching d.removeEventListener 'touchmove', @move, false d.removeEventListener 'touchend', @up, false d.removeEventListener 'touchcancel', @up, false + else # mouseup + d.removeEventListener 'mousemove', @move, false + d.removeEventListener 'mouseup', @up, false localStorage.setItem "#{g.NAMESPACE}#{@id}.position", @style.cssText hoverstart = (root, el, events, cb) ->