简体   繁体   English

使用jquery / javascript触发svg动画

[英]Triggering a svg animation with jquery/javascript

I have a .svg file that animates a circle to move using the animateMotion. 我有一个.svg文件,该文件使用animateMotion动画了一个圆以使其移动。 The problem is that I load the file with jquery at the bottom of my page. 问题是我在页面底部使用jquery加载了文件。 By the time the user has scrolled down, the animation has already played. 到用户向下滚动时,动画已经播放。 I'm using the waypoints jquery plugin which runs a function when a div is in the viewport. 我正在使用航路点jquery插件,当div在视口中时该插件会运行一个函数。 I would love to use this to trigger the animateMotion within the .svg. 我很乐意用它来触发.svg中的animateMotion。

Thoughts and ideas are greatly appreciated. 思想和想法受到极大的赞赏。


What if you simply reload the file when it comes up? 如果您只是在出现文件时重新加载该文件怎么办? That would probably run the animateMotion automatically because it will assume this is the initial loading of the file. 这可能会自动运行animateMotion,因为它将假定这是文件的初始加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM