PresenceTransition provides a declarative API to add entry and exit transitions.
const Example = () => {
const [isOpen, setIsOpen] = React.useState(false);
return <>
<Button onPress={() => setIsOpen(!isOpen)}>
Click Me to {isOpen ? "hide" : "show"}
</Button>
<PresenceTransition visible={isOpen} initial={{
opacity: 0
}} animate={{
opacity: 1,
transition: {
duration: 250
}
}}>
<Box p="40px" mt="4" bg="teal.500" rounded="md" _text={{
color: "white"
}}>
Fade
</Box>
</PresenceTransition>
</>;
};
const Example = () => {
const [isOpen, setIsOpen] = React.useState(false);
return <>
<Button onPress={() => setIsOpen(!isOpen)}>
Click Me to {isOpen ? "hide" : "show"}
</Button>
<PresenceTransition visible={isOpen} initial={{
opacity: 0,
scale: 0
}} animate={{
opacity: 1,
scale: 1,
transition: {
duration: 250
}
}}>
<Box p="40px" mt="4" bg="teal.500" rounded="md">
ScaleFade
</Box>
</PresenceTransition>
</>;
};
PresenceTransition implements
Callback invoked when transition is completed
Type: (s: "entered" | "exited") => any
Styles before the transition starts
Determines whether to start the animation
Accepts a Component to be rendered as Wrapper. Defaults to `View`
interface ISupportedTransitions {
opacity?: number;
translateY?: number;
translateX?: number;
scale?: number;
scaleX?: number;
scaleY?: number;
rotate?: string;
}
interface ITransitionStyleProps extends ISupportedTransitions {
transition?: {
type?: 'timing' | 'spring',
easing?: (value: number) => number,
overshootClamping?: boolean,
restDisplacementThreshold?: number,
restSpeedThreshold?: number,
velocity?: number | { x: number, y: number },
bounciness?: number,
speed?: number,
tension?: number,
friction?: number,
stiffness?: number,
mass?: number,
damping?: number,
delay?: number,
duration?: number,
useNativeDriver?: boolean,
};
}