Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

Preserving function on elements #19

Open
gpincheiraa opened this issue Dec 16, 2013 · 2 comments
Open

Preserving function on elements #19

gpincheiraa opened this issue Dec 16, 2013 · 2 comments

Comments

@gpincheiraa
Copy link

Ii can preserving the functions on my elements?

i've my raphael paper with much elements, and functions associated on these elements.

like ...

raphael.rect(0,0,200,100).drag(function1,function2,function3);

@AliasIO
Copy link
Owner

AliasIO commented Dec 16, 2013

You can't preserve the actual functions. You can use the callback to save some additional data however and use that to work out what should happen on restore:

var json = paper.toJSON(function(el, data) {
    data.isDraggable = true;

    return data;
});
paper.fromJSON(json, function(el, data) {
    if ( data.isDraggable ) {
        el.drag(...);
    }

    return el;
});

@jsj14
Copy link

jsj14 commented Jun 10, 2015

Is there a way to retain sets and its functions with this ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants