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.

Kinetic.Node.clone The method looks like the right thing for me, but it is not what I expect to do.

Pseudocode:

  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 (); }; };   

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 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:

  1. First of all, try to use the answer of projeqht.
  2. Secondly, you have to add images and eventholders again, with the tricks given by Mark E , you can handle it easily.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -