Files
openlayers/lib/OpenLayers/Control/DragPan.js
crschmidt f0d474e50b Change license text to point to "OpenLayers contributors", referencing
authors.txt file. In reality, MetaCarta does not own copyright to these files,
they merely have a right to distribute them under the license terms agreed to
by the contributors. At this point, there is no longer any reference to
MetaCarta as a copyright holder in the OpenLayers project, only to its
individual contributors via the authors.txt file.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@10706 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
2010-09-01 03:06:31 +00:00

95 lines
2.4 KiB
JavaScript

/* Copyright (c) 2006-2010 by OpenLayers Contributors (see authors.txt for
* full list of contributors). 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
* The DragPan control pans the map with a drag of the mouse.
*
* 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,
/**
* Property: interval
* {Integer} The number of milliseconds that should ellapse before
* panning the map again. Set this to increase dragging performance.
* Defaults to 25 milliseconds.
*/
interval: 25,
/**
* APIProperty: documentDrag
* {Boolean} If set to true, mouse dragging will continue even if the
* mouse cursor leaves the map viewport. Default is false.
*/
documentDrag: 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
}, {
interval: this.interval,
documentDrag: this.documentDrag
}
);
},
/**
* 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"
});