Merge pull request #927 from adv-isu/HandlerPathUndoTouchFix2
Improved touch support for Handler.Path.undo
This commit is contained in:
@@ -271,6 +271,16 @@ OpenLayers.Handler.Path = OpenLayers.Class(OpenLayers.Handler.Point, {
|
|||||||
var target = components[index];
|
var target = components[index];
|
||||||
var undone = geometry.removeComponent(target);
|
var undone = geometry.removeComponent(target);
|
||||||
if (undone) {
|
if (undone) {
|
||||||
|
// On touch devices, set the current ("mouse location") point to
|
||||||
|
// match the last digitized point.
|
||||||
|
if (this.touch && index > 0) {
|
||||||
|
components = geometry.components; // safety
|
||||||
|
var lastpt = components[index - 1];
|
||||||
|
var curptidx = this.getCurrentPointIndex();
|
||||||
|
var curpt = components[curptidx];
|
||||||
|
curpt.x = lastpt.x;
|
||||||
|
curpt.y = lastpt.y;
|
||||||
|
}
|
||||||
if (!this.redoStack) {
|
if (!this.redoStack) {
|
||||||
this.redoStack = [];
|
this.redoStack = [];
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-1
@@ -601,6 +601,12 @@
|
|||||||
handler.mousedown({type: "mousedown", xy: px});
|
handler.mousedown({type: "mousedown", xy: px});
|
||||||
handler.mouseup({type: "mouseup", xy: px});
|
handler.mouseup({type: "mouseup", xy: px});
|
||||||
}
|
}
|
||||||
|
function userTap(handler, x, y) {
|
||||||
|
var px = new OpenLayers.Pixel(x, y);
|
||||||
|
handler.touchstart({xy: px});
|
||||||
|
handler.touchmove({xy: px});
|
||||||
|
handler.touchend({});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editing method tests: insertXY, insertDeltaXY, insertDirectionXY,
|
* Editing method tests: insertXY, insertDeltaXY, insertDirectionXY,
|
||||||
@@ -720,7 +726,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function test_undoredo1(t) {
|
function test_undoredo1(t) {
|
||||||
t.plan(4);
|
t.plan(5);
|
||||||
var obj = editingMethodsSetup();
|
var obj = editingMethodsSetup();
|
||||||
var map = obj.map;
|
var map = obj.map;
|
||||||
var handler = obj.handler;
|
var handler = obj.handler;
|
||||||
@@ -747,6 +753,17 @@
|
|||||||
handler.redo();
|
handler.redo();
|
||||||
t.geom_eq(original, handler.line.geometry, "one redo undoes one undo");
|
t.geom_eq(original, handler.line.geometry, "one redo undoes one undo");
|
||||||
|
|
||||||
|
// add point via touch
|
||||||
|
userTap(handler, 10, 50);
|
||||||
|
handler.undo();
|
||||||
|
currentLen = handler.line.geometry.components.length;
|
||||||
|
t.geom_eq(
|
||||||
|
handler.line.geometry.components[currentLen-1],
|
||||||
|
handler.line.geometry.components[currentLen-2],
|
||||||
|
"current point (mouse position) is set to the last digitized " +
|
||||||
|
"point after undo on touch devices"
|
||||||
|
);
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
map.destroy();
|
map.destroy();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user