I have a box that contains two buttons stacked in the center. When I hover on the box, I want the buttons to transition opacity from 0 to 1 and I want to transition the transform property from translateY(20px) to translateY(0), so that they also move up. I have this effect in place, however I want to have the bottom button's animation delayed slightly when hovering, and I want the top buttons animation delayed slightly when un-hovering. How can I achieve this with react-spring?
Here is what I have
const [isHovering, setIsHovering] = useState(false);
const fadeStyles = useSpring({
from: { opacity: 0, transform: `translateY(20px)` },
to: {
opacity: isHovering ? 1 : 0,
transform: isHovering ? `translateY(0px)` : `translateY(20px)`,
},
});
return (
<div>
<animated.div style={fadeStyles}>
<Button>Change</Button>
</animated.div>
<animated.div style={fadeStyles}>
<Button>Details</Button>
</animated.div>
</div>
)