代码之家  ›  专栏  ›  技术社区  ›  buydadip

如何优化动画

  •  0
  • buydadip  · 技术社区  · 7 年前

    动画 一辆汽车沿着一条路线行驶。

    每个动画都由一个函数定义,该函数看起来像。。。

    var animate = function(current) {
    
        // If animation has not reached limit yet,
        // call the next frame.
        if (counter <= limit) {
            requestAnimationFrame(animate);
        }
    
        // Do things every second.
        if (current >= (last + 1000)) {
    
          counter += 1; 
    
          // Do stuff.
    
        }
    }
    

    我的问题是,有哪些前端优化技术可以帮助加速我的动画。我做的一个优化就是从 setInterval requestAnimationFrame ,但我不确定这到底有多大的改善。

    animate() 跑步?我不确定前端应用程序的方法是什么。

    1 回复  |  直到 7 年前