mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-17 14:23:38 +02:00
Make map pan to the location of the undone edit when undoing instead of the location of the edit before that (close #5831)
This commit is contained in:
@@ -203,13 +203,14 @@ export function coreHistory(context) {
|
||||
undo: function() {
|
||||
d3_select(document).interrupt('history.perform');
|
||||
|
||||
var previous = _stack[_index].graph;
|
||||
var previousStack = _stack[_index];
|
||||
var previous = previousStack.graph;
|
||||
while (_index > 0) {
|
||||
_index--;
|
||||
if (_stack[_index].annotation) break;
|
||||
}
|
||||
|
||||
dispatch.call('undone', this, _stack[_index]);
|
||||
dispatch.call('undone', this, _stack[_index], previousStack);
|
||||
return change(previous, true);
|
||||
},
|
||||
|
||||
@@ -218,13 +219,14 @@ export function coreHistory(context) {
|
||||
redo: function() {
|
||||
d3_select(document).interrupt('history.perform');
|
||||
|
||||
var previous = _stack[_index].graph;
|
||||
var previousStack = _stack[_index];
|
||||
var previous = previousStack.graph;
|
||||
var tryIndex = _index;
|
||||
while (tryIndex < _stack.length - 1) {
|
||||
tryIndex++;
|
||||
if (_stack[tryIndex].annotation) {
|
||||
_index = tryIndex;
|
||||
dispatch.call('redone', this, _stack[_index]);
|
||||
dispatch.call('redone', this, _stack[_index], previousStack);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-14
@@ -105,22 +105,29 @@ export function rendererMap(context) {
|
||||
osm.on('change.map', immediateRedraw);
|
||||
}
|
||||
|
||||
function didUndoOrRedo(stack, targetTransform) {
|
||||
var mode = context.mode().id;
|
||||
if (mode !== 'browse' && mode !== 'select') return;
|
||||
|
||||
var followSelected = false;
|
||||
if (Array.isArray(stack.selectedIDs)) {
|
||||
followSelected = (stack.selectedIDs.length === 1 && stack.selectedIDs[0][0] === 'n');
|
||||
context.enter(
|
||||
modeSelect(context, stack.selectedIDs).follow(followSelected)
|
||||
);
|
||||
}
|
||||
if (!followSelected && targetTransform) {
|
||||
map.transformEase(targetTransform);
|
||||
}
|
||||
}
|
||||
|
||||
context.history()
|
||||
.on('change.map', immediateRedraw)
|
||||
.on('undone.map redone.map', function(stack) {
|
||||
var mode = context.mode().id;
|
||||
if (mode !== 'browse' && mode !== 'select') return;
|
||||
|
||||
var followSelected = false;
|
||||
if (Array.isArray(stack.selectedIDs)) {
|
||||
followSelected = (stack.selectedIDs.length === 1 && stack.selectedIDs[0][0] === 'n');
|
||||
context.enter(
|
||||
modeSelect(context, stack.selectedIDs).follow(followSelected)
|
||||
);
|
||||
}
|
||||
if (!followSelected && stack.transform) {
|
||||
map.transformEase(stack.transform);
|
||||
}
|
||||
.on('undone.map', function(stack, fromStack) {
|
||||
didUndoOrRedo(stack, fromStack.transform);
|
||||
})
|
||||
.on('redone.map', function(stack) {
|
||||
didUndoOrRedo(stack, stack.transform);
|
||||
});
|
||||
|
||||
context.background()
|
||||
|
||||
Reference in New Issue
Block a user