From 56490d73cea0d4356c2083590641b932cf2f8da4 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Wed, 15 Aug 2007 20:48:17 +0000 Subject: [PATCH] #905 - give the drag handler back its start property - controls use but do not modify these handler properties git-svn-id: http://svn.openlayers.org/trunk/openlayers@3906 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Handler/Drag.js | 9 ++++++++- tests/Handler/test_Drag.html | 8 +++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/OpenLayers/Handler/Drag.js b/lib/OpenLayers/Handler/Drag.js index 6040ff2323..87be7ca253 100644 --- a/lib/OpenLayers/Handler/Drag.js +++ b/lib/OpenLayers/Handler/Drag.js @@ -40,10 +40,16 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { /** * Property: last - * {} + * {} The last pixel location of the drag. */ last: null, + /** + * Property: start + * {} The first pixel location of the drag. + */ + start: null, + /** * Property: oldOnselectstart * {Function} @@ -90,6 +96,7 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, { if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) { this.started = true; this.dragging = false; + this.start = evt.xy; this.last = evt.xy; // TBD replace with CSS classes this.map.div.style.cursor = "move"; diff --git a/tests/Handler/test_Drag.html b/tests/Handler/test_Drag.html index 96bbaee6eb..d535ba62c4 100644 --- a/tests/Handler/test_Drag.html +++ b/tests/Handler/test_Drag.html @@ -83,7 +83,7 @@ } function test_Handler_Drag_callbacks(t) { - t.plan(28); + t.plan(30); var map = new OpenLayers.Map('map', {controls: []}); @@ -141,6 +141,9 @@ map.events.triggerEvent("mousedown", testEvents.down); t.ok(handler.started, "mousedown sets the started flag to true"); t.ok(!handler.dragging, "mouse down sets the dragging flag to false"); + t.ok(handler.start.x == testEvents.down.xy.x && + handler.start.y == testEvents.down.xy.y, + "mouse down sets handler.start correctly"); t.ok(handler.last.x == testEvents.down.xy.x && handler.last.y == testEvents.down.xy.y, "mouse down sets handler.last correctly"); @@ -159,6 +162,9 @@ handler.started = true; map.events.triggerEvent("mousemove", testEvents.move); t.ok(handler.dragging, "mousemove sets the dragging flag to true"); + t.ok(handler.start.x == testEvents.down.xy.x && + handler.start.y == testEvents.down.xy.y, + "mouse move leaves handler.start alone"); t.ok(handler.last.x == testEvents.move.xy.x && handler.last.y == testEvents.move.xy.y, "mouse move sets handler.last correctly");