You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi
I have a problem with auto start animation defined with object config (no function config) in useSpring/useSprings.
This example works perfect but doesn't start animation for first item when component mounted but when user scroll the page, and when other items are visible (check visibility with intersectionObserver) everything will work perfect, even the first item animation will start to work when user scroll back to top of the page (meet the first item).
This's an example of a defined useSprings:
const styles = useSprings(
anchors.length,
anchors.map((_, idx) => ({
backgroundSize: active === idx ? '100% 5%' : '100% 0%', // active value control with intsersectionObserver
to:
active === idx
? [{ backgroundSize: '100% 100%' }, { backgroundSize: '100% 5%' }]
: { backgroundSize: '100% 0%' },
loop: active === idx,
})),
)
A solution I found is using useIsReadyWindow. This hook returns true when window !== undefind.
When the window object is ready, the component will refresh and then the first item for first time will animate.
I have this problem with any type of useSpring/useSprings for single/multiple item with config object. The defined animation won't start for first time until a handler like useIsReadyWindow hook refresh the component or user have interaction with other elements in the page to start animation.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi
I have a problem with auto start animation defined with object config (no function config) in useSpring/useSprings.
This example works perfect but doesn't start animation for first item when component mounted but when user scroll the page, and when other items are visible (check visibility with intersectionObserver) everything will work perfect, even the first item animation will start to work when user scroll back to top of the page (meet the first item).
This's an example of a defined useSprings:
A solution I found is using useIsReadyWindow. This hook returns true when window !== undefind.
When the window object is ready, the component will refresh and then the first item for first time will animate.
I have this problem with any type of useSpring/useSprings for single/multiple item with config object. The defined animation won't start for first time until a handler like useIsReadyWindow hook refresh the component or user have interaction with other elements in the page to start animation.
All packages in this project:
Thank you in advance 🌹
Beta Was this translation helpful? Give feedback.
All reactions