-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathundo.js
More file actions
33 lines (33 loc) · 889 Bytes
/
undo.js
File metadata and controls
33 lines (33 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
let undoStack;
let undoPosition;
function InitUndo() {
// First image is created by the first CreateImage()
undoStack = [];
undoPosition = -1;
let saved = localStorage.getItem("undoMaxEntries");
settings.maxUndoEntries = saved == null ? 200 : parseInt(saved);
}
function RecordUndo() {
if (undoPosition + 1 < undoStack.length)
undoStack = undoStack.slice(0, undoPosition + 1);
undoStack.push(ImageState.Get());
undoPosition++;
while (undoStack.length > settings.maxUndoEntries) {
undoStack.shift();
undoPosition--;
}
SaveHistory();
}
function Undo() {
if (undoPosition <= 0)
return;
undoPosition--;
undoStack[undoPosition].Set();
}
function Redo() {
if (undoPosition >= undoStack.length - 1)
return;
undoPosition++;
undoStack[undoPosition].Set();
}
//# sourceMappingURL=undo.js.map