mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-30 11:49:39 +02:00
Merge branch 'master' of github.com:systemed/iD
This commit is contained in:
@@ -1,7 +1,30 @@
|
||||
iD.behavior.DragNode = function(mode) {
|
||||
var history = mode.history,
|
||||
size = mode.map.size(),
|
||||
nudgeInterval,
|
||||
projection = mode.map.projection;
|
||||
|
||||
function edge(point) {
|
||||
var pad = [30, 100, 30, 100];
|
||||
if (point[0] > size[0] - pad[0]) return [-10, 0];
|
||||
else if (point[0] < pad[2]) return [10, 0];
|
||||
else if (point[1] > size[1] - pad[1]) return [0, -10];
|
||||
else if (point[1] < pad[3]) return [0, 10];
|
||||
return null;
|
||||
}
|
||||
|
||||
function startNudge(nudge) {
|
||||
if (nudgeInterval) window.clearInterval(nudgeInterval);
|
||||
nudgeInterval = window.setInterval(function() {
|
||||
mode.map.pan(nudge).redraw();
|
||||
}, 50);
|
||||
}
|
||||
|
||||
function stopNudge(nudge) {
|
||||
if (nudgeInterval) window.clearInterval(nudgeInterval);
|
||||
nudgeInterval = null;
|
||||
}
|
||||
|
||||
return iD.behavior.drag()
|
||||
.delegate(".node")
|
||||
.origin(function(entity) {
|
||||
@@ -13,11 +36,17 @@ iD.behavior.DragNode = function(mode) {
|
||||
})
|
||||
.on('move', function(entity) {
|
||||
d3.event.sourceEvent.stopPropagation();
|
||||
|
||||
var nudge = edge(d3.event.point);
|
||||
if (nudge) startNudge(nudge);
|
||||
else stopNudge();
|
||||
|
||||
history.replace(
|
||||
iD.actions.MoveNode(entity.id, projection.invert(d3.event.point)),
|
||||
'moved a node');
|
||||
})
|
||||
.on('end', function() {
|
||||
stopNudge();
|
||||
history.replace(
|
||||
iD.actions.Noop(),
|
||||
'moved a node');
|
||||
|
||||
@@ -258,9 +258,19 @@ iD.Map = function() {
|
||||
t[0] - ll[0] + c[0],
|
||||
t[1] - ll[1] + c[1]]);
|
||||
zoom.translate(projection.translate());
|
||||
dispatch.move(map);
|
||||
return true;
|
||||
}
|
||||
|
||||
map.pan = function(d) {
|
||||
var t = projection.translate();
|
||||
t[0] += d[0];
|
||||
t[1] += d[1];
|
||||
projection.translate(t);
|
||||
zoom.translate(projection.translate());
|
||||
return map;
|
||||
};
|
||||
|
||||
map.size = function(_) {
|
||||
if (!arguments.length) return dimensions;
|
||||
dimensions = _;
|
||||
|
||||
Reference in New Issue
Block a user