#774 - drag control only calls move callback with a change in pixel position - DragPan control simplified

git-svn-id: http://svn.openlayers.org/trunk/openlayers@3891 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-11 03:32:41 +00:00
parent 4de7f79d45
commit b4da05da35
3 changed files with 34 additions and 35 deletions

View File

@@ -27,7 +27,7 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
*/
draw: function() {
this.handler = new OpenLayers.Handler.Drag( this,
{"move": this.panMap, "up": this.panMapDone } );
{"move": this.panMap, "up": this.panMap} );
},
/**
@@ -37,35 +37,13 @@ OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
* xy - {<OpenLayers.Pixel>} Pixel of the up position
*/
panMap: function (xy) {
var deltaX = this.handler.start.x - xy.x;
var deltaY = this.handler.start.y - xy.y;
var deltaX = this.handler.last.x - xy.x;
var deltaY = this.handler.last.y - xy.y;
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true);
// this assumes xy won't be changed inside Handler.Drag
// a safe bet for now, and saves us the extra call to clone().
this.handler.start = xy;
},
/**
* Method: panMapDone
*
* Parameters:
* xy - {<OpenLayers.Pixel>} Pixel of the up position
*/
panMapDone: function (xy) {
var deltaX = this.handler.start.x - xy.x;
var deltaY = this.handler.start.y - xy.y;
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, false);
// this assumes xy won't be changed inside Handler.Drag
// a safe bet for now, and saves us the extra call to clone().
this.handler.start = xy;
this.map.setCenter(newCenter, null, this.handler.dragging);
},
CLASS_NAME: "OpenLayers.Control.DragPan"