return asap

This commit is contained in:
Nicolas Stepien 2012-09-22 04:00:30 +02:00
parent 92bece87ea
commit bef732ac26
2 changed files with 19 additions and 15 deletions

View File

@ -254,7 +254,8 @@
height: screenHeight - rect.height, height: screenHeight - rect.height,
width: screenWidth - rect.width, width: screenWidth - rect.width,
screenHeight: screenHeight, screenHeight: screenHeight,
screenWidth: screenWidth screenWidth: screenWidth,
isTouching: isTouching
}; };
if (isTouching) { if (isTouching) {
o.identifier = e.identifier; o.identifier = e.identifier;
@ -277,6 +278,7 @@
touch = _ref[_i]; touch = _ref[_i];
if (touch.identifier === this.identifier) { if (touch.identifier === this.identifier) {
drag.call(this, touch); drag.call(this, touch);
return;
} }
} }
}; };
@ -315,18 +317,19 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
touch = _ref[_i]; touch = _ref[_i];
if (touch.identifier === this.identifier) { if (touch.identifier === this.identifier) {
dragend.call(this, touch); dragend.call(this);
return;
} }
} }
}; };
dragend = function(e) { dragend = function() {
if (e.type === 'mouseup') { if (this.isTouching) {
d.removeEventListener('mousemove', this.move, false);
d.removeEventListener('mouseup', this.up, false);
} else {
d.removeEventListener('touchmove', this.move, false); d.removeEventListener('touchmove', this.move, false);
d.removeEventListener('touchend', this.up, false); d.removeEventListener('touchend', this.up, false);
d.removeEventListener('touchcancel', 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); return localStorage.setItem("" + g.NAMESPACE + this.id + ".position", this.style.cssText);
}; };

View File

@ -206,6 +206,7 @@ UI = (->
width: screenWidth - rect.width width: screenWidth - rect.width
screenHeight: screenHeight screenHeight: screenHeight
screenWidth: screenWidth screenWidth: screenWidth
isTouching: isTouching
} }
if isTouching if isTouching
o.identifier = e.identifier o.identifier = e.identifier
@ -223,7 +224,7 @@ UI = (->
for touch in e.changedTouches for touch in e.changedTouches
if touch.identifier is @identifier if touch.identifier is @identifier
drag.call @, touch drag.call @, touch
return return
drag = (e) -> drag = (e) ->
left = e.clientX - @dx left = e.clientX - @dx
top = e.clientY - @dy top = e.clientY - @dy
@ -246,16 +247,16 @@ UI = (->
touchend = (e) -> touchend = (e) ->
for touch in e.changedTouches for touch in e.changedTouches
if touch.identifier is @identifier if touch.identifier is @identifier
dragend.call @, touch dragend.call @
return return
dragend = (e) -> dragend = ->
if e.type is 'mouseup' if @isTouching
d.removeEventListener 'mousemove', @move, false
d.removeEventListener 'mouseup', @up, false
else # touchend or touchcancel
d.removeEventListener 'touchmove', @move, false d.removeEventListener 'touchmove', @move, false
d.removeEventListener 'touchend', @up, false d.removeEventListener 'touchend', @up, false
d.removeEventListener 'touchcancel', @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 localStorage.setItem "#{g.NAMESPACE}#{@id}.position", @style.cssText
hoverstart = (root, el, events, cb) -> hoverstart = (root, el, events, cb) ->