Hello World
Hello World

Reputation: 1129

Snap.SVG how to stop all animations

I want to find a way of stopping all animations on all rectangle elements within the SVG when a certain element is clicked. I'm trying to use something like this:

svg.select("rect").stop();

but I can't get that to work

Upvotes: 3

Views: 3459

Answers (1)

defghi1977
defghi1977

Reputation: 5349

Select all elements of a certain type and then run a forEach, passing in a function that takes each individual element.

svg.selectAll("rect").forEach(function(elem){elem.stop();});

Upvotes: 6

Related Questions