Skip to content

Commit

Permalink
Fixing example
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed May 16, 2024
1 parent 767834b commit 25c59ed
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dev/examples/useSpring.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,36 @@ const spring = {

function DragExample() {
const dragX = useMotionValue(0)
// const dragY = useMotionValue(0)
const dragY = useMotionValue(0)
const x = useSpring(dragX, spring)
// const y = useSpring(dragY, spring)
const y = useSpring(dragY, spring)
return (
<motion.div
drag="x"
dragMomentum={false}
_dragX={dragX}
// _dragY={dragY}
style={{ width: 100, height: 100, background: "red", x }}
_dragY={dragY}
style={{ width: 100, height: 100, background: "red", x, y }}
>
Drag
</motion.div>
)
}

function RerenderExample() {
const [mousePosition, setMousePosition] = useState({ x: null, y: null })
const [{ x, y }, setMousePosition] = useState({ x: null, y: null })

const updateMousePosition = useRef((e) => {
setMousePosition({ x: e.clientX, y: e.clientY })
})

const size = 40
const ref = useRef<HTMLDivElement>(null)
// console.log(x)

return (
<motion.div
ref={ref}
animate={{ x: mousePosition.x }}
animate={{ x, y }}
transition={spring}
style={{
width: 100,
Expand Down

0 comments on commit 25c59ed

Please sign in to comment.