add missing file

This commit is contained in:
DD 2017-10-05 18:12:28 -04:00
parent 345a43e127
commit 7523af09f0

45
src/helper/undo.js Normal file
View file

@ -0,0 +1,45 @@
// undo functionality
// modifed from https://github.com/memononen/stylii
import paper from 'paper';
const performSnapshot = function (dispatchPerformSnapshot) {
dispatchPerformSnapshot({
json: paper.project.exportJSON({asString: false})
});
// @todo enable/disable buttons
// updateButtonVisibility();
};
const _restore = function (entry) {
paper.project.clear();
paper.project.importJSON(entry.json);
paper.view.update();
};
const performUndo = function (undoState, dispatchPerformUndo) {
if (undoState.pointer > 0) {
_restore(undoState.stack[undoState.pointer - 1]);
dispatchPerformUndo();
// @todo enable/disable buttons
// updateButtonVisibility();
}
};
const performRedo = function (undoState, dispatchPerformRedo) {
if (undoState.pointer >= 0 && undoState.pointer < undoState.stack.length - 1) {
_restore(undoState.stack[undoState.pointer + 1]);
dispatchPerformRedo();
// @todo enable/disable buttons
// updateButtonVisibility();
}
};
export {
performSnapshot,
performUndo,
performRedo
};