Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/render/html/use-props.mjs 1.97 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
  "use client";
  import { isMotionValue, isForcedMotionValue, buildHTMLStyles } from 'motion-dom';
  import { useMemo } from 'react';
  import { createHtmlRenderState } from './utils/create-render-state.mjs';
  
  function copyRawValuesOnly(target, source, props) {
      for (const key in source) {
          if (!isMotionValue(source[key]) && !isForcedMotionValue(key, props)) {
              target[key] = source[key];
          }
      }
  }
  function useInitialMotionValues({ transformTemplate }, visualState) {
      return useMemo(() => {
          const state = createHtmlRenderState();
          buildHTMLStyles(state, visualState, transformTemplate);
          return Object.assign({}, state.vars, state.style);
      }, [visualState]);
  }
  function useStyle(props, visualState) {
      const styleProp = props.style || {};
      const style = {};
      /**
       * Copy non-Motion Values straight into style
       */
      copyRawValuesOnly(style, styleProp, props);
      Object.assign(style, useInitialMotionValues(props, visualState));
      return style;
  }
  function useHTMLProps(props, visualState) {
      // The `any` isn't ideal but it is the type of createElement props argument
      const htmlProps = {};
      const style = useStyle(props, visualState);
      if (props.drag && props.dragListener !== false) {
          // Disable the ghost element when a user drags
          htmlProps.draggable = false;
          // Disable text selection
          style.userSelect =
              style.WebkitUserSelect =
                  style.WebkitTouchCallout =
                      "none";
          // Disable scrolling on the draggable direction
          style.touchAction =
              props.drag === true
                  ? "none"
                  : `pan-${props.drag === "x" ? "y" : "x"}`;
      }
      if (props.tabIndex === undefined &&
          (props.onTap || props.onTapStart || props.whileTap)) {
          htmlProps.tabIndex = 0;
      }
      htmlProps.style = style;
      return htmlProps;
  }
  
  export { copyRawValuesOnly, useHTMLProps };
  //# sourceMappingURL=use-props.mjs.map