【问题标题】:css animation-play-state paused doesn't work in ios [duplicate]css动画播放状态暂停在ios中不起作用[重复]
【发布时间】:2015-10-22 10:56:26
【问题描述】:
body.pause * {
animation-play-state:paused !important;
-webkit-animation-play-state:paused !important;
}

当 body 上有一个类“.pause”时,我想暂停所有 css 动画。它在桌面上运行良好,但在 ipad/iphone 中不起作用。我正在ios8上测试。

我注意到的另一件事是,我正在使用步骤动画,上面的“暂停”代码暂停了步骤动画,但完全忽略了变换。

并注意到这个问题只发生在 ios Safari 中。即使是 ios 中的 Chrome 也可以。

【问题讨论】:

  • @BoltClock 你有什么想法吗?

标签: css css-animations


【解决方案1】:

使用 -webkit-animation: none !important; 而不是 -webkit-animation-play-state:paused; 的 iOS 8-9 Safari 解决方法 此方法适用于 GWD,但也可以应用其他方式

  1. 不要在 GWD (Google Web Designer) 中使用暂停事件
  2. 创建调用javascript函数的普通事件,设置“-webkit-animation: none !important;”到
    (您可以添加/删除 css 类)

    CSS 样式

    .no-animation {
      -webkit-animation: none !important;
    }
    

    Javascript

    div.className = div.className + " no-animation";
    
    1. 要恢复,请删除 CSS 类

    Javascript

    div.className = div.className.replace("no-animation", '');
    
    1. 请注意,当移除/暂停动画时,它会回到第 0 帧(00:00 秒),因此您可能需要计算 div 的当前不透明度/位置

    http://jsfiddle.net/duchuy/pczsufL9/

【讨论】:

  • 感谢@duchuy,但这仍然不是一个合适的解决方案。会向前看。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-13
  • 2021-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-02-09
  • 1970-01-01
相关资源
最近更新 更多