Clear the feature stored by the DragFeature control when the user moves the mouse out or when dragging completes (closes #942).

git-svn-id: http://svn.openlayers.org/trunk/openlayers@4111 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Tim Schaub
2007-08-29 18:56:48 +00:00
parent c2148651ed
commit 06d41662d7
2 changed files with 31 additions and 0 deletions

View File

@@ -237,6 +237,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
*/
doneDragging: function(pixel) {
this.onComplete(this.feature, pixel);
this.feature = null;
},
/**
@@ -252,6 +253,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
this.dragHandler.deactivate();
// TBD replace with CSS classes
this.map.div.style.cursor = "default";
this.feature = null;
} else {
if(this.feature.id == feature.id) {
this.over = false;

View File

@@ -165,6 +165,35 @@
}
function test_Control_DragFeature_out(t) {
t.plan(2);
var map = new OpenLayers.Map("map");
var layer = new OpenLayers.Layer.Vector();
map.addLayer(layer);
var control = new OpenLayers.Control.DragFeature(layer);
map.addControl(control);
control.activate();
// simulate a mouseover on a feature
layer.getFeatureFromEvent = function() {
return "foo";
};
map.events.triggerEvent("mousemove");
t.eq(control.feature, "foo",
"feature is set on mouse over");
// simulate a mouseout on a feature
layer.getFeatureFromEvent = function() {
return null;
};
map.events.triggerEvent("mousemove");
t.ok(control.feature == null,
"feature is set to null on mouse out");
}
</script>
</head>
<body>