Save toJSON and load Kinetic.Layer by keeping the same events that I defined and images

StackOverflow https://stackoverflow.com//questions/24026042

  •  21-12-2019
  •  | 
  •  

Is there a concrete example about saving layers that contain images + shapes + events on each node to JSON format, and then load it? What I have done until now is saving to JSON.

I want to give the user the ability to save what he has done, close his computer (his session on the website), then when he connects again, the old saved layers appear. So he can continue drawing, dragging and dropping, etc.

有帮助吗?

解决方案

As far as I know, you can only save shapes and its attributes to JSON. You can't save images and events.

After loading stage from JSON, you will have to reassign all the images again as well as the events.

Here's a tutotial from KineticJS website regarding Complex Stage Loading

Edit1: I had the same problem you're having... In order to solve this, after loading the stage, layers and shapes, I just get the shapes I want to assign events by using find on its name attribute. You may also consider using find by type for the same purpose.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top