jpcgt
jpcgt

Reputation: 2248

snapsvg - Add SVG inside SVG + events not working

I have several SVG elements in a web page and I want to nest them. The problem I'm having is that when I do this using:

top = Snap("#workspace");
inner = Snap("#child");
top.add(inner);

Then inner does not respond to events, i.e. inner.click(function....) or inner.drag() don't do what's expected. Here's a JSFiddle. The dots object is not dragable, while block is.

Upvotes: 0

Views: 151

Answers (1)

Ian
Ian

Reputation: 13842

You can't drag/transform an svg element itself, so that wouldn't work.

You can drag a g element though, so put the drag handler on that. You can do this instead.

var dots = Snap("#layer1");

jsfiddle

Upvotes: 1

Related Questions