Smooth GDragging at last. Thanks to overstdr for digging up the getDragObject method. With v2.93 and later we no longer get flickers on panning. Non-API smooth dragging is no longer supported. r=crschmidt,me (closes #1402)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6492 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1317,27 +1317,33 @@ OpenLayers.Map = OpenLayers.Class({
|
||||
* Parameters:
|
||||
* dx - {Integer}
|
||||
* dy - {Integer}
|
||||
* options - {Object} Only one at this time: "animate", which uses
|
||||
* panTo instead of setCenter. Default is true.
|
||||
* options - {Object} Options to configure panning:
|
||||
* - *animate* {Boolean} Use panTo instead of setCenter. Default is true.
|
||||
* - *dragging* {Boolean} Call setCenter with dragging true. Default is
|
||||
* false.
|
||||
*/
|
||||
pan: function(dx, dy, options) {
|
||||
|
||||
// this should be pushed to applyDefaults and extend
|
||||
if (!options) {
|
||||
options = {animate: true}
|
||||
}
|
||||
options = {};
|
||||
}
|
||||
OpenLayers.Util.applyDefaults(options, {
|
||||
animate: true,
|
||||
dragging: false
|
||||
});
|
||||
// getCenter
|
||||
var centerPx = this.getViewPortPxFromLonLat(this.getCenter());
|
||||
|
||||
// adjust
|
||||
var newCenterPx = centerPx.add(dx, dy);
|
||||
|
||||
// only call setCenter if there has been a change
|
||||
if (!newCenterPx.equals(centerPx)) {
|
||||
// only call setCenter if not dragging or there has been a change
|
||||
if (!options.dragging || !newCenterPx.equals(centerPx)) {
|
||||
var newCenterLonLat = this.getLonLatFromViewPortPx(newCenterPx);
|
||||
if (options.animate) {
|
||||
this.panTo(newCenterLonLat);
|
||||
} else {
|
||||
this.setCenter(newCenterLonLat);
|
||||
this.setCenter(newCenterLonLat, null, options.dragging);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user