zoukankan      html  css  js  c++  java
  • Web animation API improvements in Chromium 84

    基础概念:把 CSS 换成 JS

    @keyframes openAnimation {
      0% {
        transform: scale(0);
      }
      100% {
        transform: scale(1);
      }
    }
    
    换成
    
    const openAnimation = [
      { transform: 'scale(0)' },
      { transform: 'scale(1)' },
    ];
    .modal {
      animation: openAnimation 1s 1 ease-in;
    }
    
    换成
    
    document.querySelector('.modal').animate(
        openAnimation, {
          duration: 1000, // 1s
          iterations: 1, // single iteration
          easing: 'ease-in' // easing function
        }
    );

    新的功能

    1. 能监听 animation.ready 和 animation.finished

    2. New transitions can be triggered while existing ones are still running.

    可以在现有转换仍在运行时触发新转换。这个好!要自己实现会很复杂

    3. 可替换动画的性能改进

    elem.addEventListener('mousemove', evt => {
     rectangle.animate(
       { transform: translate(${evt.clientX}px, ${evt.clientY}px) },
       { duration: 500, fill: 'forwards' }
     );
    });

    例子中,mousemove 会触发非常多次,而最新的 animation 会被优化。

    如果自己实现,会需要 requestAnimation 来控制。

    4. 其他功能
    animation.replaceState(), animation.commitStyles(), animation.persist()

    5. composite mode

    有 3 种模式: replace, add, accumulate

    大概是说如果有多个 animation 要混着用,你可以选择不同的模式去执行。

    Link

  • 相关阅读:
    HDU——T 3342 Legal or Not
    Web框架本质
    February 5 2017 Week 6 Sunday
    February 4 2017 Week 5 Saturday
    February 3 2017 Week 5 Friday
    February 2 2017 Week 5 Thursday
    February 1 2017 Week 5 Wednesday
    January 31 2017 Week 5 Tuesday
    January 30 2017 Week 5 Monday
    January 29 2017 Week 5 Sunday
  • 原文地址:https://www.cnblogs.com/stooges/p/15323807.html
Copyright © 2011-2022 走看看