I am currently using useTransition to make my mobile navigation appear:
const MobileNav = ({show, toggle, styles}) => {
let transition = useTransition(show, null, {
from: {transform: 'translateY(-100%) scale(0.7)', ...styles},
enter: {transform: 'translateY(0) scale(1)'},
leave: {transform: 'translateY(100%) scale(0.7)'}
})
return (
<>
{transition.map(({item, props, key}) => {
return item ? (
<animated.div className="navbar__menu_mob" key={key} style={props}>
...someHtml
</animated.div>
) : null
})}
</>
)
}
With this code the scale and the translate animate at the same time. My end goal is to chain them so the scale
is first then the translateY
is after. From the examples by react-spring the best way seems to be wrapping the my first animated.div
in another animated.div
and chaining them using useChain
.
I seem to be struggling to understand the best way to chain my animations together. Ideally I wouldn't have to wrap what I currently have in another animated.div
. I could do with some guidance.