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:
@@ -237,6 +237,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
doneDragging: function(pixel) {
|
doneDragging: function(pixel) {
|
||||||
this.onComplete(this.feature, pixel);
|
this.onComplete(this.feature, pixel);
|
||||||
|
this.feature = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,6 +253,7 @@ OpenLayers.Control.DragFeature = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this.dragHandler.deactivate();
|
this.dragHandler.deactivate();
|
||||||
// TBD replace with CSS classes
|
// TBD replace with CSS classes
|
||||||
this.map.div.style.cursor = "default";
|
this.map.div.style.cursor = "default";
|
||||||
|
this.feature = null;
|
||||||
} else {
|
} else {
|
||||||
if(this.feature.id == feature.id) {
|
if(this.feature.id == feature.id) {
|
||||||
this.over = false;
|
this.over = false;
|
||||||
|
|||||||
@@ -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>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Reference in New Issue
Block a user