Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/animation/animate/index.mjs 2.04 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  import { GroupAnimationWithThen } from 'motion-dom';
  import { removeItem } from 'motion-utils';
  import { animateSequence } from './sequence.mjs';
  import { animateSubject } from './subject.mjs';
  
  function isSequence(value) {
      return Array.isArray(value) && value.some(Array.isArray);
  }
  /**
   * Creates an animation function that is optionally scoped
   * to a specific element.
   */
  function createScopedAnimate(options = {}) {
      const { scope, reduceMotion } = options;
      /**
       * Implementation
       */
      function scopedAnimate(subjectOrSequence, optionsOrKeyframes, options) {
          let animations = [];
          let animationOnComplete;
          if (isSequence(subjectOrSequence)) {
              const { onComplete, ...sequenceOptions } = optionsOrKeyframes || {};
              if (typeof onComplete === "function") {
                  animationOnComplete = onComplete;
              }
              animations = animateSequence(subjectOrSequence, reduceMotion !== undefined
                  ? { reduceMotion, ...sequenceOptions }
                  : sequenceOptions, scope);
          }
          else {
              // Extract top-level onComplete so it doesn't get applied per-value
              const { onComplete, ...rest } = options || {};
              if (typeof onComplete === "function") {
                  animationOnComplete = onComplete;
              }
              animations = animateSubject(subjectOrSequence, optionsOrKeyframes, (reduceMotion !== undefined
                  ? { reduceMotion, ...rest }
                  : rest), scope);
          }
          const animation = new GroupAnimationWithThen(animations);
          if (animationOnComplete) {
              animation.finished.then(animationOnComplete);
          }
          if (scope) {
              scope.animations.push(animation);
              animation.finished.then(() => {
                  removeItem(scope.animations, animation);
              });
          }
          return animation;
      }
      return scopedAnimate;
  }
  const animate = createScopedAnimate();
  
  export { animate, createScopedAnimate };
  //# sourceMappingURL=index.mjs.map