Don't stop every touches when only one ends.

This commit is contained in:
Nicolas Stepien 2012-09-16 16:40:05 +02:00
parent 6b0f739237
commit 0897fe5c5b
2 changed files with 19 additions and 5 deletions

View File

@ -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);

View File

@ -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