Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/motion/features/definitions.mjs 1.46 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
  import { getFeatureDefinitions, setFeatureDefinitions } from 'motion-dom';
  
  const featureProps = {
      animation: [
          "animate",
          "variants",
          "whileHover",
          "whileTap",
          "exit",
          "whileInView",
          "whileFocus",
          "whileDrag",
      ],
      exit: ["exit"],
      drag: ["drag", "dragControls"],
      focus: ["whileFocus"],
      hover: ["whileHover", "onHoverStart", "onHoverEnd"],
      tap: ["whileTap", "onTap", "onTapStart", "onTapCancel"],
      pan: ["onPan", "onPanStart", "onPanSessionStart", "onPanEnd"],
      inView: ["whileInView", "onViewportEnter", "onViewportLeave"],
      layout: ["layout", "layoutId"],
  };
  let isInitialized = false;
  /**
   * Initialize feature definitions with isEnabled checks.
   * This must be called before any motion components are rendered.
   */
  function initFeatureDefinitions() {
      if (isInitialized)
          return;
      const initialFeatureDefinitions = {};
      for (const key in featureProps) {
          initialFeatureDefinitions[key] = {
              isEnabled: (props) => featureProps[key].some((name) => !!props[name]),
          };
      }
      setFeatureDefinitions(initialFeatureDefinitions);
      isInitialized = true;
  }
  /**
   * Get the current feature definitions, initializing if needed.
   */
  function getInitializedFeatureDefinitions() {
      initFeatureDefinitions();
      return getFeatureDefinitions();
  }
  
  export { getInitializedFeatureDefinitions, initFeatureDefinitions };
  //# sourceMappingURL=definitions.mjs.map