Files
openlayers/lib/OpenLayers/Control/DragPan.js
crschmidt 53b20137cb Finish pullups for RC2.
#1498 Easily turning off/overriding default select and temporary intent
        styles
  #1501 GeoRSS format tests fail in Safari
  #1502 Events register method fails if listeners member is not an array
  #1503 panning off for odd-sized viewport
  #1504 doc review


git-svn-id: http://svn.openlayers.org/branches/openlayers/2.6@6835 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2008-04-09 17:58:44 +00:00

73 lines
1.7 KiB
JavaScript

/* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
* license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
* full text of the license. */
/**
* @requires OpenLayers/Control.js
* @requires OpenLayers/Handler/Drag.js
*/
/**
* Class: OpenLayers.Control.DragPan
* DragPan control.
*
* Inherits from:
* - <OpenLayers.Control>
*/
OpenLayers.Control.DragPan = OpenLayers.Class(OpenLayers.Control, {
/**
* Property: type
* {OpenLayers.Control.TYPES}
*/
type: OpenLayers.Control.TYPE_TOOL,
/**
* Property: panned
* {Boolean} The map moved.
*/
panned: false,
/**
* Method: draw
* Creates a Drag handler, using <panMap> and
* <panMapDone> as callbacks.
*/
draw: function() {
this.handler = new OpenLayers.Handler.Drag(this,
{"move": this.panMap, "done": this.panMapDone});
},
/**
* Method: panMap
*
* Parameters:
* xy - {<OpenLayers.Pixel>} Pixel of the mouse position
*/
panMap: function(xy) {
this.panned = true;
this.map.pan(
this.handler.last.x - xy.x,
this.handler.last.y - xy.y,
{dragging: this.handler.dragging, animate: false}
);
},
/**
* Method: panMapDone
* Finish the panning operation. Only call setCenter (through <panMap>)
* if the map has actually been moved.
*
* Parameters:
* xy - {<OpenLayers.Pixel>} Pixel of the mouse position
*/
panMapDone: function(xy) {
if(this.panned) {
this.panMap(xy);
this.panned = false;
}
},
CLASS_NAME: "OpenLayers.Control.DragPan"
});