make the drag handler and drag feature control tidy up after themselves - as a bonus, give the drag feature control an onStart method. Thanks for the review crschmidt (closes #950).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4147 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-30 23:25:49 +00:00
parent 17a4129b55
commit cecf760f29
4 changed files with 31 additions and 7 deletions

View File

@@ -24,6 +24,19 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
*/
geometryTypes: null,
/**
* APIProperty: onStart
* {Function} Define this function if you want to know when a drag starts.
* The function should expect to receive two arguments: the feature
* that is about to be dragged and the pixel location of the mouse.
*
* Parameters:
* feature - {OpenLayers.Feature.Vector} The feature that is about to be
* dragged.
* pixel - {OpenLayers.Pixel} The pixel location of the mouse.
*/
onStart: function(feature, pixel) {},
/**
* APIProperty: onDrag
* {Function} Define this function if you want to know about each move of a
@@ -154,6 +167,9 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
// the return from the handlers is unimportant in this case
this.dragHandler.deactivate();
this.featureHandler.deactivate();
this.feature = null;
this.dragging = false;
this.lastPixel = null;
return OpenLayers.Control.prototype.deactivate.apply(this, arguments);
},
@@ -189,8 +205,8 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
* pixel - {OpenLayers.Pixel} Location of the mouse event.
*/
downFeature: function(pixel) {
this.dragHandler.dragging = true;
this.lastPixel = pixel;
this.onStart(this.feature, pixel);
},
/**

View File

@@ -282,7 +282,10 @@ OpenLayers.Handler.Drag = OpenLayers.Class(OpenLayers.Handler, {
deactivate: function() {
var deactivated = false;
if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) {
this.started = false;
this.dragging = false;
this.start = null;
this.last = null;
deactivated = true;
}
return deactivated;