fix up issue with Sencha Touch example not handling double tap to zoom in, r=elemoine (closes #3079)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11226 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -96,6 +96,12 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
||||
*/
|
||||
last: null,
|
||||
|
||||
/**
|
||||
* Property: touch
|
||||
* {Boolean} Are we on a touch enabled device? Default is false.
|
||||
*/
|
||||
touch: false,
|
||||
|
||||
/**
|
||||
* Property: rightclickTimerId
|
||||
* {Number} The id of the right mouse timeout waiting to clear the
|
||||
@@ -148,6 +154,7 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
||||
* {Boolean} Continue propagating this event.
|
||||
*/
|
||||
touchstart: function(evt) {
|
||||
this.touch = true;
|
||||
this.down = evt;
|
||||
this.last = null;
|
||||
return true;
|
||||
@@ -279,6 +286,10 @@ OpenLayers.Handler.Click = OpenLayers.Class(OpenLayers.Handler, {
|
||||
* {Boolean} Continue propagating this event.
|
||||
*/
|
||||
click: function(evt) {
|
||||
// Sencha Touch emulates click events, see ticket 3079 for more info
|
||||
if (this.touch === true && evt.type === "click") {
|
||||
return !this.stopSingle;
|
||||
}
|
||||
if(this.passesTolerance(evt)) {
|
||||
if(this.timerId != null) {
|
||||
// already received a click
|
||||
|
||||
@@ -329,6 +329,43 @@
|
||||
});
|
||||
}
|
||||
|
||||
function test_touch_ignoresimulatedclick(t) {
|
||||
t.plan(2);
|
||||
|
||||
// set up
|
||||
|
||||
var log;
|
||||
|
||||
var map = new OpenLayers.Map('map');
|
||||
var control = {map: map};
|
||||
|
||||
var callbacks = {
|
||||
'dblclick': function(e) {
|
||||
log.dblclick = {x: e.xy.x, y: e.xy.y,
|
||||
lastTouches: e.lastTouches};
|
||||
}
|
||||
};
|
||||
|
||||
var handler = new OpenLayers.Handler.Click(
|
||||
control, callbacks,
|
||||
{'double': true, pixelTolerance: null});
|
||||
|
||||
// test
|
||||
|
||||
log = {};
|
||||
handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
|
||||
handler.touchend({});
|
||||
handler.touchstart({xy: {x: 1, y: 1}, touches: ["foo"]});
|
||||
handler.touchend({type: "click"});
|
||||
|
||||
t.eq(handler.touch, true, "Touch property should be true");
|
||||
|
||||
t.ok(log.dblclick == undefined, "dblclick callback not called with simulated click");
|
||||
|
||||
// tear down
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_touch_dblclick(t) {
|
||||
t.plan(5);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user