From 53984809ce9f6ad1e0ca59434e891d6b13eb6853 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 3 May 2011 14:09:09 +0000 Subject: [PATCH] Handler.Feature may not trigger click when touching a feature, r=sbrunner git-svn-id: http://svn.openlayers.org/trunk/openlayers@11943 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Handler/Feature.js | 4 ++-- tests/Handler/Feature.html | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Handler/Feature.js b/lib/OpenLayers/Handler/Feature.js index 46da4a1750..9b76232af2 100644 --- a/lib/OpenLayers/Handler/Feature.js +++ b/lib/OpenLayers/Handler/Feature.js @@ -271,7 +271,7 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, { var type = evt.type; var handled = false; var previouslyIn = !!(this.feature); // previously in a feature - var click = (type == "click" || type == "dblclick"); + var click = (type == "click" || type == "dblclick" || type == "touchstart"); this.feature = this.layer.getFeatureFromEvent(evt); if(this.feature && !this.feature.layer) { // feature has been destroyed @@ -282,7 +282,7 @@ OpenLayers.Handler.Feature = OpenLayers.Class(OpenLayers.Handler, { this.lastFeature = null; } if(this.feature) { - if(evt.type === "touchstart") { + if(type === "touchstart") { // stop the event to prevent Android Webkit from // "flashing" the map div OpenLayers.Event.stop(evt); diff --git a/tests/Handler/Feature.html b/tests/Handler/Feature.html index 4c3641aa33..c2ed697984 100644 --- a/tests/Handler/Feature.html +++ b/tests/Handler/Feature.html @@ -123,7 +123,7 @@ } function test_callbacks(t) { - t.plan(13); + t.plan(14); var map = new OpenLayers.Map('map', {controls: []}); var control = new OpenLayers.Control(); @@ -235,6 +235,12 @@ evtPx.type = "touchstart"; map.events.triggerEvent('touchstart', evtPx); + // test touchstart on the same feature + // 'click' callback should be called + callbacks['click'] = getCallback('click (touch)', newFeature); + evtPx.type = "touchstart"; + map.events.triggerEvent('touchstart', evtPx); + // test touchstart in new feature and out of last feature // both 'click' and 'clickout' callbacks should be called lastFeature = newFeature;