making drawing handler work on touch devices. p=sbrunner, r=me (closes #3072)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11563 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2011-02-27 15:00:38 +00:00
parent ba8aed56ef
commit 33eef42075
7 changed files with 535 additions and 48 deletions

View File

@@ -223,12 +223,12 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
* Returns:
* {Boolean} Allow event propagation
*/
mousedown: function(evt) {
down: function(evt) {
var stopDown = this.stopDown;
if(this.freehandMode(evt)) {
stopDown = true;
}
if(!this.lastDown || !this.lastDown.equals(evt.xy)) {
if (!this.touch && (!this.lastDown || !this.passesTolerance(this.lastDown, evt.xy, this.pixelTolerance))) {
this.modifyFeature(evt.xy, !!this.lastUp);
}
this.mouseDown = true;
@@ -248,7 +248,7 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
* Returns:
* {Boolean} Allow event propagation
*/
mousemove: function (evt) {
move: function (evt) {
if(this.stoppedDown && this.freehandMode(evt)) {
if(this.persist) {
this.destroyPersistedFeature();
@@ -256,7 +256,7 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
this.addPoint(evt.xy);
return false;
}
if(!this.mouseDown || this.stoppedDown) {
if (!this.touch && (!this.mouseDown || this.stoppedDown)) {
this.modifyFeature(evt.xy, !!this.lastUp);
}
return true;
@@ -273,13 +273,17 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
* Returns:
* {Boolean} Allow event propagation
*/
mouseup: function (evt) {
if(this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
up: function (evt) {
if (this.mouseDown && (!this.lastUp || !this.passesTolerance(
this.lastUp, evt.xy, this.dblclickTolerance))) {
if(this.stoppedDown && this.freehandMode(evt)) {
this.removePoint();
this.finalize();
} else {
if(this.lastDown.equals(evt.xy)) {
if (this.passesTolerance(this.lastDown, evt.xy, this.pixelTolerance)) {
if (this.touch) {
this.modifyFeature(evt.xy);
}
if(this.lastUp == null && this.persist) {
this.destroyPersistedFeature();
}
@@ -290,7 +294,15 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
}
this.stoppedDown = this.stopDown;
this.mouseDown = false;
return !this.stopUp;
return !this.stopUp && !this.isDblclick;
},
/**
* Method: finishTouchGeometry
* Finish the geometry and send it back to the control.
*/
finishTouchGeometry: function() {
this.finishGeometry();
},
/**