add onEnter and onLeave callback functions to the DragFeature control, p=adube, r=me (closes #3034)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11071 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -71,11 +71,14 @@
|
||||
}
|
||||
|
||||
function test_Control_DragFeature_over(t) {
|
||||
t.plan(3);
|
||||
t.plan(5);
|
||||
var log = [];
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
var control = new OpenLayers.Control.DragFeature(layer);
|
||||
var control = new OpenLayers.Control.DragFeature(layer, {
|
||||
onEnter: function(f) { log.push({feature: f}); }
|
||||
});
|
||||
map.addControl(control);
|
||||
|
||||
control.activate();
|
||||
@@ -94,6 +97,10 @@
|
||||
"control gets the proper feature from the feature handler");
|
||||
t.ok(control.handlers.drag.active,
|
||||
"drag handler activated when over a feature");
|
||||
t.eq(log.length, 1,
|
||||
"onEnter called exactly once");
|
||||
t.eq(log[0].feature.id, feature.id,
|
||||
"onEnter called with expected feature");
|
||||
}
|
||||
|
||||
function test_Control_DragFeature_down(t) {
|
||||
@@ -241,11 +248,14 @@
|
||||
}
|
||||
|
||||
function test_Control_DragFeature_out(t) {
|
||||
t.plan(2);
|
||||
t.plan(4);
|
||||
var log = [];
|
||||
var map = new OpenLayers.Map("map");
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
var control = new OpenLayers.Control.DragFeature(layer);
|
||||
var control = new OpenLayers.Control.DragFeature(layer, {
|
||||
onLeave: function(f) { log.push({feature: f}); }
|
||||
});
|
||||
map.addControl(control);
|
||||
|
||||
control.activate();
|
||||
@@ -268,7 +278,10 @@
|
||||
map.events.triggerEvent("mousemove", {type: "mousemove"});
|
||||
t.ok(control.feature == null,
|
||||
"feature is set to null on mouse out");
|
||||
|
||||
t.eq(log.length, 1,
|
||||
"onLeave called exactly once");
|
||||
t.eq(log[0].feature.id, feature.id,
|
||||
"onLeave called with expected feature");
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user