fix regression where drawing accurately is not possible anymore, r=jorix,bbinet (closes #3272)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@11962 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Éric Lemoine
2011-05-09 09:34:19 +00:00
parent e87e1c0c57
commit fef7e4febf
4 changed files with 70 additions and 60 deletions

View File

@@ -35,6 +35,14 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
*/
maxVertices: null,
/**
* Property: doubleTouchTolerance
* {Number} Maximum number of pixels between two touches for
* the gesture to be considered a "finalize feature" action.
* Default is 20.
*/
doubleTouchTolerance: 20,
/**
* Property: freehand
* {Boolean} In freehand mode, the handler starts the path on mouse down,
@@ -241,9 +249,9 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
*/
touchstart: function(evt) {
if (this.timerId &&
this.passesTolerance(this.lastTouchPx, evt.xy, this.dblclickTolerance)) {
this.passesTolerance(this.lastTouchPx, evt.xy,
this.doubleTouchTolerance)) {
// double-tap, finalize the geometry
this.lastTouchPx = evt.xy; // for up() to detect dblclick and do nothing
this.finishGeometry();
window.clearTimeout(this.timerId);
this.timerId = null;
@@ -277,7 +285,9 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
if(this.freehandMode(evt)) {
stopDown = true;
}
if (!this.touch && (!this.lastDown || !this.passesTolerance(this.lastDown, evt.xy, this.pixelTolerance))) {
if (!this.touch && (!this.lastDown ||
!this.passesTolerance(this.lastDown, evt.xy,
this.pixelTolerance))) {
this.modifyFeature(evt.xy, !!this.lastUp);
}
this.mouseDown = true;
@@ -323,13 +333,13 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
* {Boolean} Allow event propagation
*/
up: function (evt) {
if (this.mouseDown && (!this.lastUp || !this.passesTolerance(
this.lastUp, evt.xy, this.dblclickTolerance))) {
if (this.mouseDown && (!this.lastUp || !this.lastUp.equals(evt.xy))) {
if(this.stoppedDown && this.freehandMode(evt)) {
this.removePoint();
this.finalize();
} else {
if (this.passesTolerance(this.lastDown, evt.xy, this.pixelTolerance)) {
if (this.passesTolerance(this.lastDown, evt.xy,
this.pixelTolerance)) {
if (this.touch) {
this.modifyFeature(evt.xy);
}