diff --git a/4chan_x.user.js b/4chan_x.user.js index 1d5c73cc3..3f3c818a5 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -223,7 +223,7 @@ }; UI = (function() { - var dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchmove; + var dialog, drag, dragend, dragstart, hover, hoverend, hoverstart, touchend, touchmove; dialog = function(id, position, html) { var el, move; el = d.createElement('div'); @@ -259,7 +259,7 @@ if (isTouching) { o.identifier = e.identifier; o.move = touchmove.bind(o); - o.up = dragend.bind(o); + o.up = touchend.bind(o); d.addEventListener('touchmove', o.move, false); d.addEventListener('touchend', o.up, false); return d.addEventListener('touchcancel', o.up, false); @@ -277,7 +277,6 @@ touch = _ref[_i]; if (touch.identifier === this.identifier) { drag.call(this, touch); - return; } } }; @@ -310,6 +309,16 @@ return this.style.bottom = null; } }; + touchend = function(e) { + var touch, _i, _len, _ref; + _ref = e.changedTouches; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + touch = _ref[_i]; + if (touch.identifier === this.identifier) { + dragend.call(this, touch); + } + } + }; dragend = function(e) { if (e.type === 'mouseup') { d.removeEventListener('mousemove', this.move, false); diff --git a/script.coffee b/script.coffee index d3f9aec80..3eb0e1fc1 100644 --- a/script.coffee +++ b/script.coffee @@ -210,7 +210,7 @@ UI = (-> if isTouching o.identifier = e.identifier o.move = touchmove.bind o - o.up = dragend.bind o + o.up = touchend.bind o d.addEventListener 'touchmove', o.move, false d.addEventListener 'touchend', o.up, false d.addEventListener 'touchcancel', o.up, false @@ -223,7 +223,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 @@ -243,6 +243,11 @@ UI = (-> else @style.top = top / @screenHeight * 100 + '%' @style.bottom = null + 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