From 5826bf5f3b19944cdd28c72fd3cf870ae28e1efb Mon Sep 17 00:00:00 2001 From: ahocevar Date: Fri, 25 Feb 2011 18:14:29 +0000 Subject: [PATCH] make tween panning use Map::moveByPx. p=aabt, r=me (closes #3098) git-svn-id: http://svn.openlayers.org/trunk/openlayers@11536 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Map.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/lib/OpenLayers/Map.js b/lib/OpenLayers/Map.js index dc5d2edce6..1767db2af9 100644 --- a/lib/OpenLayers/Map.js +++ b/lib/OpenLayers/Map.js @@ -1606,31 +1606,25 @@ OpenLayers.Map = OpenLayers.Class({ return; } - var from = { - lon: center.lon, - lat: center.lat - }; - var to = { - lon: lonlat.lon, - lat: lonlat.lat - }; - this.panTween.start(from, to, this.panDuration, { + var from = this.getPixelFromLonLat(center); + var to = this.getPixelFromLonLat(lonlat); + var vector = { x: to.x - from.x, y: to.y - from.y }; + var last = { x: 0, y: 0 }; + + this.panTween.start( { x: 0, y: 0 }, vector, this.panDuration, { callbacks: { - start: OpenLayers.Function.bind(function(lonlat) { + start: OpenLayers.Function.bind(function() { this.events.triggerEvent("movestart"); }, this), - eachStep: OpenLayers.Function.bind(function(lonlat) { - lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); - this.moveTo(lonlat, this.zoom, { - 'dragging': true, - 'noEvent': true - }); + eachStep: OpenLayers.Function.bind(function(px) { + var x = px.x - last.x, + y = px.y - last.y; + this.moveByPx(x, y); + last.x = Math.round(px.x); + last.y = Math.round(px.y); }, this), - done: OpenLayers.Function.bind(function(lonlat) { - lonlat = new OpenLayers.LonLat(lonlat.lon, lonlat.lat); - this.moveTo(lonlat, this.zoom, { - 'noEvent': true - }); + done: OpenLayers.Function.bind(function(px) { + this.moveTo(lonlat, this.zoom, {noEvent: true}); this.events.triggerEvent("moveend"); }, this) }