You can create custom animations by passing a function to the containerStyle parameter in showNotification. This function receives an Animated.Value named translateY as its first argument.
The translateY lifecycle:
-1000: Notification is completely hidden.-200: Notification is likely still hidden but will be visible soon (depending on component height).0: Notification is fully shown.
Note on Android Shadows: If you animate opacity on components with shadows (like NotifierComponents.Notification), shadows may not animate correctly on Android. To fix this, pass needsOffscreenAlphaCompositing: true via the containerProps parameter.
Note on iOS Scaling: If scaling animations (e.g., scale) cause the component to move up/down unexpectedly on iOS, it is due to SafeAreaView padding. You can fix this by moving the safe area inset to the container via containerStyle and replacing the ContainerComponent with a standard View.
const getContainerStyleWithTranslateAndScale = (translateY: Animated.Value) => ({
transform: [
{
// this interpolation is used just to "clamp" the value and didn't allow to drag the notification below "0"
translateY: translateY.interpolate({
inputRange: [-1000, 0],
outputRange: [-1000, 0],
extrapolate: 'clamp',
}),
},
{
// scaling from 0 to 0.5 when value is in range of -1000 and -200 because mostly it is still invisible,
// and from 0.5 to 1 in last 200 pixels to make the scaling effect more noticeable.
scale: translateY.interpolate({
inputRange: [-1000, -200, 0],
outputRange: [0, 0.5, 1],
extrapolate: 'clamp',
}),
},
],
});
Notifier.showNotification({
title: 'Custom animations',
description: 'This notification is moved and scaled',
containerStyle: getContainerStyleWithTranslateAndScale,
})