burnpanck
burnpanck

Reputation: 2196

Generate svg.js object for a (SVG) DOM node not created by svg.js

I use svg.js to create an SVG image within a HTML document. However, I want to add a few elements that are not created by svg.js, but rather some other code. I know that there is the .svg() method that takes SVG source and adds it, but I have the actual DOM element, which is already part of the SVG. Is there a way to get an svg.js object for this DOM element?

Upvotes: 0

Views: 673

Answers (1)

Fuzzyma
Fuzzyma

Reputation: 8524

What you are searching for is the SVG.adopt() method which takes a node and returns an SVG.js object.

You can also use the SVG.select() method which takes a css selector and returns a set of SVG.js elements. Because it's a set (sort of array) you need to get the first element with SVG.select(something).get(0)

Upvotes: 3

Related Questions