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

Commit f9fa062

Browse files
committed
v0.5.2
2 parents 879878f + 48fa39f commit f9fa062

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.5.2
2+
* Reset undo stack when loadSnapshot is called, fixing a memory leak
3+
* Moving shapes with the selection tool is on the undo stack
4+
15
v0.5.1:
26
* Fixes for React dependency
37
* Undo support for moving selected shapes

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Literally Canvas v0.5.1
1+
Literally Canvas v0.5.2
22
=======================
33

44
Literally Canvas is an extensible, open source (BSD-licensed), HTML5 drawing

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
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "literallycanvas",
3-
"version": "0.5.1",
3+
"version": "0.5.2",
44
"description": "HTML5 drawing widget",
55
"main": "lib/js",
66
"scripts": {

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

src/core/shapes.coffee

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,23 @@ defineShape 'Image',
122122
@y = args.y or 0
123123
@scale = args.scale or 1
124124
@image = args.image or null
125+
@crossOrigin = (args.image and args.image.crossOrigin) or null
125126
getBoundingRect: ->
126127
{@x, @y, width: @image.width * @scale, height: @image.height * @scale}
127-
toJSON: -> {@x, @y, imageSrc: @image.src, imageObject: @image, @scale}
128+
toJSON: () ->
129+
toJSONData = {@x, @y, imageSrc: @image.src, imageObject: @image, @scale}
130+
if @crossOrigin
131+
toJSONData['crossOrigin'] = @crossOrigin
132+
return toJSONData
128133
fromJSON: (data) ->
129134
img = null
130135
if data.imageObject?.width
131136
img = data.imageObject
132137
else
133138
img = new Image()
134139
img.src = data.imageSrc
140+
if data.crossOrigin
141+
img.crossOrigin = data.crossOrigin
135142
createShape('Image', {x: data.x, y: data.y, image: img, scale: data.scale})
136143
move: ( moveInfo={} ) ->
137144
@x = @x - moveInfo.xDiff

0 commit comments

Comments
 (0)