Optimize history and fix nodes pollution + fix css + removes motion.framer (#28)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: https://git.siklos-chaneru.duckdns.org/Siklos/svg-layout-designer-react/pulls/28
This commit is contained in:
Siklos 2022-08-12 16:31:37 -04:00
parent 704dab7307
commit d6eb9ea364
11 changed files with 196 additions and 575 deletions

View file

@ -27,14 +27,15 @@ export function SelectContainer(
throw new Error('[SelectContainer] Cannot find container among children of main container!');
}
setHistory(history.concat([{
LastAction: `Select container ${selectedContainer.properties.id}`,
history.push({
LastAction: `Select ${selectedContainer.properties.id}`,
MainContainer: mainContainerClone,
SelectedContainer: selectedContainer,
SelectedContainerId: selectedContainer.properties.id,
TypeCounters: Object.assign({}, current.TypeCounters)
}]));
setHistoryCurrentStep(history.length);
});
setHistory(history);
setHistoryCurrentStep(history.length - 1);
}
/**
@ -87,14 +88,15 @@ export function DeleteContainer(
container.parent;
const SelectedContainerId = SelectedContainer.properties.id;
setHistory(history.concat([{
LastAction: `Delete container ${containerId}`,
history.push({
LastAction: `Delete ${containerId}`,
MainContainer: mainContainerClone,
SelectedContainer,
SelectedContainerId,
TypeCounters: Object.assign({}, current.TypeCounters)
}]));
setHistoryCurrentStep(history.length);
});
setHistory(history);
setHistoryCurrentStep(history.length - 1);
}
/**
@ -235,12 +237,13 @@ export function AddContainer(
}
// Update the state
setHistory(history.concat([{
history.push({
LastAction: 'Add container',
MainContainer: clone,
SelectedContainer: parentClone,
SelectedContainerId: parentClone.properties.id,
TypeCounters: newCounters
}]));
setHistoryCurrentStep(history.length);
});
setHistory(history);
setHistoryCurrentStep(history.length - 1);
}