Blame view

天文台pc/tianwentai-ui/node_modules/motion-dom/dist/es/animation/waapi/start-waapi-animation.mjs 1.38 KB
bc518174   王天杨   提交两个项目文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
  import { activeAnimations } from '../../stats/animation-count.mjs';
  import { statsBuffer } from '../../stats/buffer.mjs';
  import { mapEasingToNativeEasing } from './easing/map-easing.mjs';
  
  function startWaapiAnimation(element, valueName, keyframes, { delay = 0, duration = 300, repeat = 0, repeatType = "loop", ease = "easeOut", times, } = {}, pseudoElement = undefined) {
      const keyframeOptions = {
          [valueName]: keyframes,
      };
      if (times)
          keyframeOptions.offset = times;
      const easing = mapEasingToNativeEasing(ease, duration);
      /**
       * If this is an easing array, apply to keyframes, not animation as a whole
       */
      if (Array.isArray(easing))
          keyframeOptions.easing = easing;
      if (statsBuffer.value) {
          activeAnimations.waapi++;
      }
      const options = {
          delay,
          duration,
          easing: !Array.isArray(easing) ? easing : "linear",
          fill: "both",
          iterations: repeat + 1,
          direction: repeatType === "reverse" ? "alternate" : "normal",
      };
      if (pseudoElement)
          options.pseudoElement = pseudoElement;
      const animation = element.animate(keyframeOptions, options);
      if (statsBuffer.value) {
          animation.finished.finally(() => {
              activeAnimations.waapi--;
          });
      }
      return animation;
  }
  
  export { startWaapiAnimation };
  //# sourceMappingURL=start-waapi-animation.mjs.map