Fixed problems with touch events on a scrollable page

This commit is contained in:
Gregers Gram Rygg
2012-11-02 14:12:29 +01:00
parent 8d0da09454
commit a2a391d3b5
9 changed files with 266 additions and 43 deletions

View File

@@ -97,6 +97,10 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {
};
this.callback("start", [evt, this.start]);
propagate = !this.stopDown;
} else if (this.started) {
// Some webkit versions send fake single-touch events during
// multitouch, which cause the drag handler to trigger
return false;
} else {
this.started = false;
this.start = null;
@@ -125,6 +129,11 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {
this.last = current;
// prevent document dragging
OpenLayers.Event.stop(evt);
return false;
} else if (this.started) {
// Some webkit versions send fake single-touch events during
// multitouch, which cause the drag handler to trigger
return false;
}
return true;
},
@@ -140,12 +149,13 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {
* {Boolean} Let the event propagate.
*/
touchend: function(evt) {
if (this.started) {
if (this.started && !OpenLayers.Event.isMultiTouch(evt)) {
this.started = false;
this.pinching = false;
this.callback("done", [evt, this.start, this.last]);
this.start = null;
this.last = null;
return false;
}
return true;
},
@@ -199,8 +209,8 @@ OpenLayers.Handler.Pinch = OpenLayers.Class(OpenLayers.Handler, {
var t0 = touches[0];
var t1 = touches[1];
return Math.sqrt(
Math.pow(t0.clientX - t1.clientX, 2) +
Math.pow(t0.clientY - t1.clientY, 2)
Math.pow(t0.olClientX - t1.olClientX, 2) +
Math.pow(t0.olClientY - t1.olClientY, 2)
);
},