mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-20 18:13:30 +00:00
27 lines
852 B
JavaScript
27 lines
852 B
JavaScript
iD.behavior.DragMidpoint = function(mode) {
|
|
var history = mode.history,
|
|
projection = mode.map.projection;
|
|
|
|
return iD.behavior.drag()
|
|
.delegate(".midpoint")
|
|
.origin(function(d) {
|
|
return projection(d.loc);
|
|
})
|
|
.on('start', function(d) {
|
|
d.node = iD.Node({loc: d.loc});
|
|
history.perform(
|
|
iD.actions.AddNode(d.node),
|
|
iD.actions.AddWayNode(d.way, d.node.id, d.index));
|
|
})
|
|
.on('move', function(d) {
|
|
d3.event.sourceEvent.stopPropagation();
|
|
history.replace(
|
|
iD.actions.MoveNode(d.node.id, projection.invert(d3.event.point)));
|
|
})
|
|
.on('end', function() {
|
|
history.replace(
|
|
iD.actions.Noop(),
|
|
'added a node to a way');
|
|
});
|
|
};
|