简体   繁体   中英

How to get the SVG root element in Snap.svg?

In Raphael it is easy to get the SVG root element:

svg_item = Raphael(0, 0, 3000, 3000);
svg_item.canvas.id = "main_svg";
svg_item.canvas.style.pointerEvents = "none";

but how this can be done in Snap.svg? The following doesn't work:

svg_item = Snap(3000, 3000);
svg_item.canvas.id = "main_svg";
svg_item.canvas.style.pointerEvents = "none";

Found the answer:

svg_item = Snap(3000, 3000);
svg_item.root.node.id = "main_svg";
svg_item.root.node.style.pointerEvents = "none";

Try paper rather than canvas, so..

svg_item.paper.id = "main_svg";
svg_item.paper.attr({ style: "pointer-events: none" });

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