Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/examples/ScreenTransitionExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function ScreenC({ navigation }: NativeStackScreenProps<ParamListBase>) {
const Stack = createNativeStackNavigator();

const customTransition: AnimatedScreenTransition = {
topScreenFrame: (event, screenSize) => {
topScreenStyle: (event, screenSize) => {
'worklet';
const progress = event.translationX / screenSize.width;
return {
Expand All @@ -62,7 +62,7 @@ const customTransition: AnimatedScreenTransition = {
],
};
},
belowTopScreenFrame: (event, screenSize) => {
belowTopScreenStyle: (event, screenSize) => {
'worklet';
const progress = event.translationX / screenSize.width;
return {
Expand Down
4 changes: 2 additions & 2 deletions src/reanimated2/screenTransition/commonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export type PanGestureHandlerEventPayload = {
};

export type AnimatedScreenTransition = {
topScreenFrame: (
topScreenStyle: (
event: PanGestureHandlerEventPayload,
screenDimensions: MeasuredDimensions
) => Record<string, unknown>;
belowTopScreenFrame: (
belowTopScreenStyle: (
event: PanGestureHandlerEventPayload,
screenDimensions: MeasuredDimensions
) => Record<string, unknown>;
Expand Down
32 changes: 16 additions & 16 deletions src/reanimated2/screenTransition/presets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand All @@ -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: [
Expand All @@ -71,7 +71,7 @@ const SwipeUp: AnimatedScreenTransition = {
};

const TwoDimensional: AnimatedScreenTransition = {
topScreenFrame: (event, _screenSize) => {
topScreenStyle: (event, _screenSize) => {
'worklet';
return {
transform: [
Expand All @@ -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 {};
},
Expand Down
11 changes: 7 additions & 4 deletions src/reanimated2/screenTransition/styleUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
};
Expand All @@ -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)],
};
Expand Down