Some Examples » 33. Layout animation
33. Layout animation
Give a motion element a layout
property and it will automatically animate when its position (or size) changes.
Code component
The motion.div
s are in a grid, which defines their actual position. What makes them change position is the fact that their key
s are changed.
The code inside useEffect()
runs every time the items
array (provided by useCycle()
) changes,… which will be every second because that’s when the setTimeout()
inside it calls setItems()
again.