[Feature request] [Layout animations] An option to skip entering/exiting animations if the element's parent is mounted/unmounted #2513
Replies: 10 comments 4 replies
-
I had a similar issue, I wanted to skip entering (exiting is fine). I couldn't find a workaround. Can you please share your workarounds? I tried to condtionally set
This however does not ever animate, its' weird. |
Beta Was this translation helpful? Give feedback.
-
My current workaround looks like this:
|
Beta Was this translation helpful? Give feedback.
-
It would be nice to see a "disabled" prop on the component so animations can be disabled/enabled as required. |
Beta Was this translation helpful? Give feedback.
-
This feature to disable/cancel layout animation when unmount/unfocus screen would be useful, even more when using navigation (navigation transition animation + exiting animation are ugly and sometimes next screen become unresponsive). |
Beta Was this translation helpful? Give feedback.
-
This way we can do this. const isScreenMountedRef = useRef(false);
useEffect(() => {
isScreenMountedRef.current = true;
}, []);
<Animated.View entering={isScreenMountedRef.current ? SlideInUp : null}
exiting={SlideOutUp}>
// code
</Animated.View> |
Beta Was this translation helpful? Give feedback.
-
This workaround also works with |
Beta Was this translation helpful? Give feedback.
-
Still looking for a workaround to prevent exiting animations on unmount. Has anyone come up with a solution for this? |
Beta Was this translation helpful? Give feedback.
-
I am working on a solution in #5045. It should be getting merged soon |
Beta Was this translation helpful? Give feedback.
-
In the meantime I stumbled on a work around for hiding exit animations by setting the parent view to |
Beta Was this translation helpful? Give feedback.
-
#5045 has been merged. It will be available in the next release (and is currently available via nightly). docs |
Beta Was this translation helpful? Give feedback.
-
I believe it is a fairly common use case when one would want elements to enter/exit with an animation only if their parent stays unchanged. Examples of such use cases may include:
Here is the
AnimatedList
example with several items added to the list by default and animation duration increased to 1 second:Simulator.Screen.Recording.-.iPhone.11.Pro.-.2021-10-08.at.20.02.05.mp4
Because of this, currently the application of layout animations is severely limited without applying ugly workarounds (like, in the first case, storing a timestamp when the list item was added and passing
undefined
to theentering
prop if the time is less than the time of mounting the parent).Beta Was this translation helpful? Give feedback.
All reactions