Some Examples » 13. Drag: Transform
13. Drag: Transform
This example uses the useMotionValue()
and useTransform()
hooks to transform the drag distance (x
) to scale
and rotate
values.
Pretty simple. The box is made draggable (only horizontally), with drag constraints that let it bounce back. And its snap-to-constraints animation is tweaked a bit.
There’s an x
Motion value passed to the box through style
so that we’ll get its horizontal position, which we transform with useTransform()
to scale
and rotate
values.