Fixes #229 and road closing nodes. Order matters for history.replace

This commit is contained in:
Tom MacWright
2012-12-11 15:58:17 -05:00
parent 435b7f46fc
commit b18ba11a09
3 changed files with 19 additions and 15 deletions
+13 -8
View File
@@ -21,11 +21,11 @@ iD.modes.DrawArea = function(wayId) {
iD.actions.AddNode(node),
iD.actions.AddWayNode(way.id, node.id, -1));
map.surface.on('mousemove.drawarea', function() {
function mousemove() {
history.replace(iD.actions.Move(node.id, map.mouseCoordinates()));
});
}
map.surface.on('click.drawarea', function() {
function click() {
var datum = d3.select(d3.event.target).datum() || {};
if (datum.id === tailId) {
@@ -52,16 +52,16 @@ iD.modes.DrawArea = function(wayId) {
controller.enter(iD.modes.DrawArea(wayId));
}
});
}
map.keybinding().on('⎋.drawarea', function() {
function esc() {
history.replace(
iD.actions.DeleteNode(node.id));
controller.enter(iD.modes.Browse());
});
}
map.keybinding().on('⌫.drawarea', function() {
function del() {
d3.event.preventDefault();
history.replace(
@@ -69,7 +69,12 @@ iD.modes.DrawArea = function(wayId) {
iD.actions.DeleteNode(headId));
controller.enter(iD.modes.DrawArea(wayId));
});
}
map.surface.on('mousemove.drawarea', mousemove);
map.surface.on('click.drawarea', click);
map.keybinding().on('⎋.drawarea', esc);
map.keybinding().on('⌫.drawarea', del);
};
mode.exit = function() {
+1 -1
View File
@@ -57,7 +57,7 @@ iD.modes.DrawRoad = function(wayId, direction) {
} else if (datum.type === 'way') {
// connect the way to an existing way
var connectedIndex = iD.modes.chooseIndex(datum, d3.mouse(map.surface.node()), map);
var connectedIndex = iD.util.geo.chooseIndex(datum, d3.mouse(map.surface.node()), map);
history.replace(
iD.actions.AddWayNode(datum.id, node.id, connectedIndex),
+5 -6
View File
@@ -134,24 +134,23 @@ iD.Map = function() {
var handles = g.hit.selectAll('image.handle')
.filter(filter)
.data(waynodes, key);
function olderOnTop(a, b) {
return a.osmId() - b.osmId();
}
handles.exit().remove();
handles.enter().append('image')
handles.enter().insert('image', ':first-child')
.attr({
width: 6,
height: 6,
'class': 'handle',
'xlink:href': 'css/handle.png'
});
handles.attr('transform', function(entity) {
var p = projection(entity.loc);
return 'translate(' + [~~p[0], ~~p[1]] +
') translate(-3, -3) rotate(45, 3, 3)';
})
.classed('active', classActive)
.sort(olderOnTop);
.classed('active', classActive);
}
function drawAccuracyHandles(waynodes, filter) {