I have an SVG set as a background image of an element. The first time the element is displayed, the animation plays correctly.
On subsequent displays (e.g. if a dupl
I think in many scenarios setCurrentTime(0)
is the best solution -- if supported by the browser. Here is an example (assuming you use the tag for embedding, of course):
let content = document.getElementById("object-id").contentDocument;
let svg = content.getElementsByTagName("svg")[0];
if(svg.getCurrentTime() > 10)
svg.setCurrentTime(0);
More infos about the relevant API can be found here: https://developer.mozilla.org/en-US/docs/Web/API/SVGSVGElement