clone - Unable to create accurate copy of a Kinetic.js stage / layer -
I am trying to create a change in history rather than a history of history, I have chosen to save the whole thing. This becomes problematic because every copy of the object updates happens with the original object.
Pseudocode: How can I make an exact copy of the forum? The best way to create a history system is to do a serial after each operation. As stored values, store your layers / elements using the Kinetic.Node.clone The method looks like the right thing for me, but it is not what I expect to do.
var history = function () {var h = this; H.history = []; H.pointer = -1; H.save = function () {h.history = h.history.slice (0, h.pointer); H.history.push (im.Stage.createCopy ()); H.movePointer (1); }; H.movePointer = function (diff) {h.pointer + = diff; (H pointer & lt; 0 & amp; amp; (h. Pointer = 0)); (H pointer> = h.history.length & amp; amp; (h.pointer = h.history.length-1)); Returns H. Pointer; }; H.render = function () {im.Stage = h.history [h.pointer] .createCopy (); Im.Stage.draw (); }; H.undo = function () {h.movePointer (-1); H.render (); }; H.redo = function () {h.movePointer (1); H.render (); }; };
layer.toJSON () .
If you use images on layers and eventholders that you want to display / work after restoring anything from history, then you have to replace images and event handlers again for items / layers / etc Because JSN () does not store images and eventholders, this huge data is stored. Make your history like this:
Comments
Post a Comment