【问题标题】:Javascript animation not working in SafariJavascript 动画在 Safari 中不起作用
【发布时间】:2018-07-31 07:13:43
【问题描述】:

我有一个代码会逐个淡化。代码从演示中进行了一些修改。演示在这里:http://thenewcode.com/1178/Create-a-Word-Fade-In-Effect-Using-the-Web-Animation-API

代码:

function fadeWords(thequote) {
    time=0;
    first = true;
  Array.prototype.forEach.call(thequote, function(word,i) {
    timspan=  i * 150;
    let animate = word.animate([{
      opacity: 0,
      filter: "blur("+getRandom(2,5)+"px)"
    }, {
      opacity: 1,
      filter: "blur(0px)"
    }], 
    { 
      duration: 600,
      delay: timspan,
      fill: 'forwards'
    } 
   )

  })
}

Safari 给我错误:未定义不是函数('...word.animate...' 附近)

如果我取消我所做的修改,该演示仍然无法在 Safari 中运行。

【问题讨论】:

    标签: javascript jquery-animate


    【解决方案1】:

    我认为这在 Safari 中不受支持: 检查浏览器兼容性:

    https://developer.mozilla.org/en-US/docs/Web/API/Element/animate#Browser_compatibility

    https://caniuse.com/#feat=web-animation

    你需要使用 polyfill 来让你的代码工作:https://github.com/web-animations/web-animations-js

    【讨论】:

    • 谢谢您,先生!非常感谢您的帮助:)
    猜你喜欢
    • 2015-04-24
    • 2015-10-14
    • 1970-01-01
    • 2019-03-05
    • 2015-08-15
    • 1970-01-01
    • 1970-01-01
    • 2011-04-13
    • 1970-01-01
    相关资源
    最近更新 更多