motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.84k stars 850 forks source link

[DOCS] Parameter error for useInView root example #2840

Open Debbl opened 1 month ago

Debbl commented 1 month ago

Describe the bug

Parameter error for useInView root example

https://www.framer.com/motion/use-in-view/###root

the root should be at second parameter

function Carousel() {
  const container = useRef(null)
  const ref = useRef(null)
-  const isInView = useInView({ root: container })
+  const isInView = useInView(ref, { root: container })

  return (
    <div ref={container} style={{ overflow: "scroll" }}>
      <div ref={ref} />
    </div>
  )
}
image

The margin is also.

https://www.framer.com/motion/use-in-view/###margin

image