Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/animation/optimized-appear/handoff.mjs 1.34 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
  import { appearAnimationStore } from './store.mjs';
  import { appearStoreId } from './store-id.mjs';
  
  function handoffOptimizedAppearAnimation(elementId, valueName, frame) {
      const storeId = appearStoreId(elementId, valueName);
      const optimisedAnimation = appearAnimationStore.get(storeId);
      if (!optimisedAnimation) {
          return null;
      }
      const { animation, startTime } = optimisedAnimation;
      function cancelAnimation() {
          window.MotionCancelOptimisedAnimation?.(elementId, valueName, frame);
      }
      /**
       * We can cancel the animation once it's finished now that we've synced
       * with Motion.
       *
       * Prefer onfinish over finished as onfinish is backwards compatible with
       * older browsers.
       */
      animation.onfinish = cancelAnimation;
      if (startTime === null || window.MotionHandoffIsComplete?.(elementId)) {
          /**
           * If the startTime is null, this animation is the Paint Ready detection animation
           * and we can cancel it immediately without handoff.
           *
           * Or if we've already handed off the animation then we're now interrupting it.
           * In which case we need to cancel it.
           */
          cancelAnimation();
          return null;
      }
      else {
          return startTime;
      }
  }
  
  export { handoffOptimizedAppearAnimation };
  //# sourceMappingURL=handoff.mjs.map