简体   繁体   中英

Raphael: How to add/remove or show/hide Paper

I see Raphael has a Paper.remove() function which removes the paper from the dom, but does it have a Paper.waitPutItBack() function that I'm not seeing? I realize I could manipulate the svg object directly, or put it inside a div and manipulate that to avoid vml troubles, but it seems like if there is a native remove-from-dom function there should also be a native add-to-dom function I'm missing.

No, it doesn't: the remove function is a deletion, with recursive deletions of nodes and event listeners.

R.prototype.remove = function () {
    eve("raphael.remove", this);
    this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas);
    for (var i in this) {
        this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null;
    }
};

You can however hide the DOM node of the paper container by setting the display property to none, and expect everything to work when you display as block again. For example, hit the play button and then quickly click through toggle to show the moving animation.: http://jsfiddle.net/Cy8DQ/2/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM