Some Examples » 5. Reverse
5. Reverse
When using repeat
, you can add a repeatType
of "reverse"
to make the animation go back and forth.
Code component
export default function CC_05_Reverse(props) {
return (
<div>
<motion.div
style={{
width: 150,
height: 150,
borderRadius: 30,
backgroundColor: "#fff",
}}
animate={{ rotate: 360 }}
transition={{
duration: 2,
repeat: Infinity,
repeatType: "reverse",
}}
/>
</div>
)
}
Code override
export function Reverse(Component): ComponentType {
return (props) => {
return (
<Component
{...props}
animate={{ rotate: 360 }}
transition={{
duration: 2,
repeat: Infinity,
repeatType: "reverse",
}}
/>
)
}
}