[OpenLayers-Commits] r11615 - in
sandbox/tschaub/click/lib/OpenLayers: Control Handler
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Fri Mar 4 16:06:32 EST 2011
Author: tschaub
Date: 2011-03-04 13:06:31 -0800 (Fri, 04 Mar 2011)
New Revision: 11615
Modified:
sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js
sandbox/tschaub/click/lib/OpenLayers/Handler/Click.js
Log:
Making the click handler tolerant to stopped touchstart. Making the PinchZoom control tolerant to no pinch move.
Modified: sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js 2011-03-03 18:12:54 UTC (rev 11614)
+++ sandbox/tschaub/click/lib/OpenLayers/Control/PinchZoom.js 2011-03-04 21:06:31 UTC (rev 11615)
@@ -124,6 +124,7 @@
*/
pinchStart: function(evt, pinchData) {
this.pinchOrigin = evt.xy;
+ this.currentCenter = evt.xy;
},
/**
Modified: sandbox/tschaub/click/lib/OpenLayers/Handler/Click.js
===================================================================
--- sandbox/tschaub/click/lib/OpenLayers/Handler/Click.js 2011-03-03 18:12:54 UTC (rev 11614)
+++ sandbox/tschaub/click/lib/OpenLayers/Handler/Click.js 2011-03-04 21:06:31 UTC (rev 11615)
@@ -158,7 +158,10 @@
* {Boolean} Continue propagating this event.
*/
touchstart: function(evt) {
- this.touch = true;
+ if (!this.touch) {
+ this.unregisterMouseListeners();
+ this.touch = true;
+ }
this.down = this.getEventInfo(evt);
this.last = this.getEventInfo(evt);
return true;
@@ -183,12 +186,28 @@
* touches property from last touchstart or touchmove
*/
touchend: function(evt) {
- // touchend doesn't come with a pixel position or touches
- evt.xy = this.last.xy;
- evt.lastTouches = this.last.touches;
- this.handleSingle(evt);
+ // touchstart may not have been allowed to propagate
+ if (this.down) {
+ evt.xy = this.last.xy;
+ evt.lastTouches = this.last.touches;
+ this.handleSingle(evt);
+ }
return true;
},
+
+ /**
+ * Method: unregisterMouseListeners
+ * In a touch environment, we don't want to handle mouse events.
+ */
+ unregisterMouseListeners: function() {
+ this.map.events.un({
+ mousedown: this.mousedown,
+ mouseup: this.mouseup,
+ click: this.click,
+ dblclick: this.dblclick,
+ scope: this
+ });
+ },
/**
* Method: mousedown
@@ -198,10 +217,8 @@
* {Boolean} Continue propagating this event.
*/
mousedown: function(evt) {
- if (!this.touch) {
- this.down = this.getEventInfo(evt);
- this.last = this.getEventInfo(evt);
- }
+ this.down = this.getEventInfo(evt);
+ this.last = this.getEventInfo(evt);
return true;
},
@@ -285,12 +302,10 @@
* {Boolean} Continue propagating this event.
*/
click: function(evt) {
- if (!this.touch) {
- if (!this.last) {
- this.last = this.getEventInfo(evt);
- }
- this.handleSingle(evt);
+ if (!this.last) {
+ this.last = this.getEventInfo(evt);
}
+ this.handleSingle(evt);
return !this.stopSingle;
},
@@ -306,9 +321,7 @@
* {Boolean} Continue propagating this event.
*/
dblclick: function(evt) {
- if (!this.touch) {
- this.handleDouble(evt);
- }
+ this.handleDouble(evt);
return !this.stopDouble;
},
More information about the Commits
mailing list