【问题标题】:Is there a way to delay the restart in SVG animateTransform有没有办法在 SVG animateTransform 中延迟重启
【发布时间】:2015-05-07 22:19:33
【问题描述】:

我正在尝试沿其轴旋转我的 SVG 图像,我可以使用以下代码成功地做到这一点:

<animateTransform attributeName="transform"
                  type="rotate"
                  from="120 262.5 125"
                  to="0 262.5 125"
                  begin="2s"
                  dur="2s"
                  repeatCount="indefinite"
 />

我的问题是,是否有办法将动画的重新启动处理一两秒。将 repeatCount 设置为不确定的,它会立即重新启动它。

提前致谢!

更新

我已经尝试了下面给出的代码,但它并没有按照我需要的方式工作。它需要围绕 svg 的中心轴旋转,但在重新启动之前暂停大约一秒钟。有什么想法吗?

最终更新

如果将来有人在搜索此问题时看到此问题,我将提供我能够做的事情以使其正常工作。通过添加一个 id、更改开始时间和 repeatCount,我成功地获得了重复旋转,其间有延迟。

代码如下:

<animateTransform id="rotation" attributeName="transform"
                  type="rotate"
                  from="120 262.5 125"
                  to="0 262.5 125"
                  begin="2+rotation.end+2"
                  dur="2s"
                  repeatCount=1
 />

【问题讨论】:

标签: javascript css html image svg


【解决方案1】:

试试下面的代码

<animateTransform attributeName="transform"
    type="rotate"
    from="120 262.5 125"
    to="0 262.5 125"
    begin="0"
    dur="2s"
    repeatCount="indefinite"
    keyTimes="0;0.75;1" 
     values="0 54.2 43.3 ; 0 54.2 43.3 ; 360 54.2 43.3"
 />

此处动画开始是相对于动画结束指定的,这样您的动画将始终等待您指定的时间(此处为 4 秒)并重新开始播放...

【讨论】:

  • 这并不能完全解决它。它确实造成了一点延迟,但轮换完全不正常。也许如果我稍微玩一下数字......
猜你喜欢
  • 2012-10-13
  • 2016-02-17
  • 2016-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-11
  • 2012-12-30
  • 2020-08-31
相关资源
最近更新 更多