diff --git a/app/src/examples/ScreenTransitionExample.tsx b/app/src/examples/ScreenTransitionExample.tsx index d9951707b358..0368322a4798 100644 --- a/app/src/examples/ScreenTransitionExample.tsx +++ b/app/src/examples/ScreenTransitionExample.tsx @@ -52,7 +52,7 @@ function ScreenC({ navigation }: NativeStackScreenProps) { const Stack = createNativeStackNavigator(); const customTransition: AnimatedScreenTransition = { - topScreenFrame: (event, screenSize) => { + topScreenStyle: (event, screenSize) => { 'worklet'; const progress = event.translationX / screenSize.width; return { @@ -62,7 +62,7 @@ const customTransition: AnimatedScreenTransition = { ], }; }, - belowTopScreenFrame: (event, screenSize) => { + belowTopScreenStyle: (event, screenSize) => { 'worklet'; const progress = event.translationX / screenSize.width; return { diff --git a/src/reanimated2/screenTransition/commonTypes.ts b/src/reanimated2/screenTransition/commonTypes.ts index ec1442460ba1..a265c214c3e5 100644 --- a/src/reanimated2/screenTransition/commonTypes.ts +++ b/src/reanimated2/screenTransition/commonTypes.ts @@ -18,11 +18,11 @@ export type PanGestureHandlerEventPayload = { }; export type AnimatedScreenTransition = { - topScreenFrame: ( + topScreenStyle: ( event: PanGestureHandlerEventPayload, screenDimensions: MeasuredDimensions ) => Record; - belowTopScreenFrame: ( + belowTopScreenStyle: ( event: PanGestureHandlerEventPayload, screenDimensions: MeasuredDimensions ) => Record; diff --git a/src/reanimated2/screenTransition/presets.ts b/src/reanimated2/screenTransition/presets.ts index 42132d3b8fdb..e1dd51709de6 100644 --- a/src/reanimated2/screenTransition/presets.ts +++ b/src/reanimated2/screenTransition/presets.ts @@ -3,13 +3,13 @@ import type { AnimatedScreenTransition } from './commonTypes'; const SwipeRight: AnimatedScreenTransition = { - topScreenFrame: (event) => { + topScreenStyle: (event) => { 'worklet'; return { transform: [{ translateX: event.translationX }], }; }, - belowTopScreenFrame: (event, screenSize) => { + belowTopScreenStyle: (event, screenSize) => { 'worklet'; return { transform: [ @@ -20,13 +20,13 @@ const SwipeRight: AnimatedScreenTransition = { }; const SwipeLeft: AnimatedScreenTransition = { - topScreenFrame: (event) => { + topScreenStyle: (event) => { 'worklet'; return { transform: [{ translateX: event.translationX }], }; }, - belowTopScreenFrame: (event, screenSize) => { + belowTopScreenStyle: (event, screenSize) => { 'worklet'; return { transform: [ @@ -37,13 +37,13 @@ const SwipeLeft: AnimatedScreenTransition = { }; const SwipeDown: AnimatedScreenTransition = { - topScreenFrame: (event) => { + topScreenStyle: (event) => { 'worklet'; return { transform: [{ translateY: event.translationY }], }; }, - belowTopScreenFrame: (event, screenSize) => { + belowTopScreenStyle: (event, screenSize) => { 'worklet'; return { transform: [ @@ -54,13 +54,13 @@ const SwipeDown: AnimatedScreenTransition = { }; const SwipeUp: AnimatedScreenTransition = { - topScreenFrame: (event) => { + topScreenStyle: (event) => { 'worklet'; return { transform: [{ translateY: event.translationY }], }; }, - belowTopScreenFrame: (event, screenSize) => { + belowTopScreenStyle: (event, screenSize) => { 'worklet'; return { transform: [ @@ -71,7 +71,7 @@ const SwipeUp: AnimatedScreenTransition = { }; const TwoDimensional: AnimatedScreenTransition = { - topScreenFrame: (event, _screenSize) => { + topScreenStyle: (event, _screenSize) => { 'worklet'; return { transform: [ @@ -80,46 +80,46 @@ const TwoDimensional: AnimatedScreenTransition = { ], }; }, - belowTopScreenFrame: (_event, _screenSize) => { + belowTopScreenStyle: (_event, _screenSize) => { 'worklet'; return {}; }, }; const Horizontal: AnimatedScreenTransition = { - topScreenFrame: (event, _screenSize) => { + topScreenStyle: (event, _screenSize) => { 'worklet'; return { transform: [{ translateX: event.translationX }], }; }, - belowTopScreenFrame: (_event, _screenSize) => { + belowTopScreenStyle: (_event, _screenSize) => { 'worklet'; return {}; }, }; const Vertical: AnimatedScreenTransition = { - topScreenFrame: (event, _screenSize) => { + topScreenStyle: (event, _screenSize) => { 'worklet'; return { transform: [{ translateY: event.translationY }], }; }, - belowTopScreenFrame: (_event, _screenSize) => { + belowTopScreenStyle: (_event, _screenSize) => { 'worklet'; return {}; }, }; const SwipeRightFade: AnimatedScreenTransition = { - topScreenFrame: (event, screenSize) => { + topScreenStyle: (event, screenSize) => { 'worklet'; return { opacity: 1 - Math.abs(event.translationX / screenSize.width), }; }, - belowTopScreenFrame: (_event, _screenSize) => { + belowTopScreenStyle: (_event, _screenSize) => { 'worklet'; return {}; }, diff --git a/src/reanimated2/screenTransition/styleUpdater.ts b/src/reanimated2/screenTransition/styleUpdater.ts index 133c25f84037..41c547b3b34a 100644 --- a/src/reanimated2/screenTransition/styleUpdater.ts +++ b/src/reanimated2/screenTransition/styleUpdater.ts @@ -29,8 +29,8 @@ function applyStyleForTopScreen( 'worklet'; const { screenDimensions, topScreenId, screenTransition } = screenTransitionConfig; - const { topScreenFrame } = screenTransition; - const topScreenStyle = topScreenFrame(event, screenDimensions); + const { topScreenStyle: computeTopScreenStyle } = screenTransition; + const topScreenStyle = computeTopScreenStyle(event, screenDimensions); const topScreenDescriptor = { value: [createViewDescriptor(topScreenId)], }; @@ -48,8 +48,11 @@ export function applyStyleForBelowTopScreen( 'worklet'; const { screenDimensions, belowTopScreenId, screenTransition } = screenTransitionConfig; - const { belowTopScreenFrame } = screenTransition; - const belowTopScreenStyle = belowTopScreenFrame(event, screenDimensions); + const { belowTopScreenStyle: computeBelowTopScreenStyle } = screenTransition; + const belowTopScreenStyle = computeBelowTopScreenStyle( + event, + screenDimensions + ); const belowTopScreenDescriptor = { value: [createViewDescriptor(belowTopScreenId)], };