0.0.9 • Published 2 years ago

nice-hooks-fn v0.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

useIntersectionObserver()

监听页面滚动,指定的元素是否处于浏览器窗口视图内

浏览器api,IntersectionObserver不兼容IE

function App() {
  const $ref = useRef();
  const inView = useIntersectionObserver($ref);
  return <div ref={$ref}>元素</div>
}

usePages()

function App() {
  const view = usePage({
    pageIdx: 1,
    pageSize: 3,
    allList: [1, 2, 3, 4, 5, 6, 7, 8, 9]
  });
  return <div>
    {view.map((item) => <span>{item}</span>)}
  </div>
}