Catch changes on SVG element circle and change attributes elsewhere via js

前端 未结 3 1456
感情败类
感情败类 2021-01-26 17:12

I have an embedded SVG in an HTML document. An (SVG) circle is animated using . I was trying to find a way to put some kind of event listener on that

3条回答
  •  無奈伤痛
    2021-01-26 17:37

    An event is fired when animations begin, end or repeat but not (as you want) whenever there is a change of animation value.

    As animations are deterministic though you can just start the rect shape animation so many seconds after the circle animation starts.

    var cx = myCircle.cx.animVal.value;
    

    will give you the animated value if you need it, provided that's the attribute you're animating.

    You're using animateMotion rather than animating the cx and cy attributes on their own though. I'm think the only way to get the circle position post that transform is to call getBBox.

提交回复
热议问题