transitionBehavior
transitionBehavior
lets you determine whether the transition is applied to discrete properties. Defaults to normal
which transitions only continuous properties and discards discrete properties.
Reference
function App() {
return (
<Animated.View
style={{
transitionProperty: 'alignItems',
transitionDuration: 500,
transitionBehavior: 'allowDiscrete',
}}
/>
);
}
Type definitions
type CSSTransitionBehavior = 'normal' | 'allowDiscrete';
Values
allowDiscrete
Allows transitions to be applied to discrete properties, resulting in delayed changes.
normal
Doesn't allow transitions to be applied to discrete properties, resulting in changes applied immediately.
Example
Remarks
Discrete style properties (like
flexDirection
,justifyContent
) can't be smoothly animated using thetransitionProperty
property. For example, you can't animate smoothly fromalignItems: start
toalignItems: center
. You can use Layout Animations to animate discrete style properties instead.When using
allowDiscrete
the discrete properties flip between two values at the midpoint of the animation, except for thedisplay
property, which is immediately at the moment of the transition start.
Platform compatibility
Android | iOS | Web |
---|---|---|
✅ | ✅ | ✅ |