Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

Commit 48fa39f

Browse files
authored
Merge pull request #493 from anx-ckreuzberger/master
Fixing issue #492 (reset undoStack to improve memory usage), improving core demo
2 parents fa1bcdd + f597cfc commit 48fa39f

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.*.* (Upcoming release)
2+
* Reset undostack when loadSnapshot is called
3+
* Store moving a shape with the SelectTool in undoStack
4+
15
v0.5.0:
26
* Support for React 15 & 16
37
* Fix XSS vulnerabilities in text tool (interactive & SVG output)

demo/core_demo.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@
8686
<a href="javascript:void(0);" class='tool' id="hide-lc">Teardown</a>
8787
<a href="javascript:void(0);" class='tool' id="show-lc">Setup</a>
8888
<a href="javascript:void(0);" class='tool' id="clear-lc">Clear</a>
89+
<a href="javascript:void(0);" class='tool' id="undo-lc">Undo</a>
90+
<a href="javascript:void(0);" class='tool' id="redo-lc">Redo</a>
8991
</div>
9092

9193
<div class="toolset">
@@ -204,6 +206,14 @@
204206
lc.clear();
205207
});
206208

209+
$("#undo-lc").click(function() {
210+
lc.undo();
211+
});
212+
213+
$("#redo-lc").click(function() {
214+
lc.redo();
215+
});
216+
207217
// Set up our own tools...
208218
tools = [
209219
{

src/core/LiterallyCanvas.coffee

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,11 @@ module.exports = class LiterallyCanvas
486486
@setColor(k, snapshot.colors[k])
487487

488488
if snapshot.shapes
489+
# reset shapes
489490
@shapes = []
491+
# reset undostack aswell when loading a snapshot
492+
@undostack = []
493+
490494
for shapeRepr in snapshot.shapes
491495
shape = JSONToShape(shapeRepr)
492496
@execute(new actions.AddShapeAction(this, shape)) if shape

0 commit comments

Comments
 (0)