Blame view

天文台pc/tianwentai-ui/node_modules/framer-motion/dist/es/utils/use-in-view.mjs 801 Bytes
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
  "use client";
  import { useState, useEffect } from 'react';
  import { inView } from '../render/dom/viewport/index.mjs';
  
  function useInView(ref, { root, margin, amount, once = false, initial = false, } = {}) {
      const [isInView, setInView] = useState(initial);
      useEffect(() => {
          if (!ref.current || (once && isInView))
              return;
          const onEnter = () => {
              setInView(true);
              return once ? undefined : () => setInView(false);
          };
          const options = {
              root: (root && root.current) || undefined,
              margin,
              amount,
          };
          return inView(ref.current, onEnter, options);
      }, [root, ref, margin, once, amount]);
      return isInView;
  }
  
  export { useInView };
  //# sourceMappingURL=use-in-view.mjs.map