diff --git a/example/package.json b/example/package.json index ccf93ccc..d7c07acd 100644 --- a/example/package.json +++ b/example/package.json @@ -18,11 +18,13 @@ "predeploy": "yarn build:web" }, "dependencies": { + "@faker-js/faker": "^6.0.0-beta.0", "@react-navigation/core": "^6.1.0", "@react-navigation/native": "^6.0.6", "@react-navigation/native-stack": "^6.2.5", "babel-loader": "^8.2.3", "expo": "^41.0.0", + "expo-blur": "~9.0.3", "expo-constants": "~10.1.3", "expo-splash-screen": "~0.10.2", "react": "16.13.1", diff --git a/example/src/flow/index.tsx b/example/src/flow/index.tsx new file mode 100644 index 00000000..057d1ce1 --- /dev/null +++ b/example/src/flow/index.tsx @@ -0,0 +1,157 @@ +import * as React from 'react'; +import { interpolate } from 'react-native-reanimated'; +import Carousel from 'react-native-reanimated-carousel'; +import type { TAnimationStyle } from '../../../src/layouts/BaseLayout'; +import { window } from '../constants'; +import { useHeaderHeight } from '@react-navigation/elements'; +import { Text, View } from 'react-native-ui-lib'; +import { BlurView } from 'expo-blur'; +import { faker } from '@faker-js/faker'; +import { Image } from 'react-native'; + +function Index() { + const headerHeight = useHeaderHeight(); + const scale = 0.9; + + const RIGHT_OFFSET = window.width * (1 - scale); + + const ITEM_WIDTH = window.width * scale; + const ITEM_HEIGHT = 120; + + const PAGE_HEIGHT = window.height - headerHeight; + const PAGE_WIDTH = window.width; + + const animationStyle: TAnimationStyle = React.useCallback( + (value: number) => { + 'worklet'; + + const translateY = interpolate( + value, + [-1, 0, 1], + [-ITEM_HEIGHT, 0, ITEM_HEIGHT] + ); + const right = interpolate( + value, + [-1, -0.2, 1], + [RIGHT_OFFSET / 2, RIGHT_OFFSET, RIGHT_OFFSET / 3] + ); + return { + transform: [{ translateY }], + right, + }; + }, + [RIGHT_OFFSET] + ); + + return ( + + + + { + return ( + + + + + > = [ ]; const CustomAnimations: Array> = [ + { + name: 'Flow', + }, { name: 'AdvancedParallax', }, diff --git a/example/src/index.tsx b/example/src/index.tsx index 12b151ba..d329db17 100644 --- a/example/src/index.tsx +++ b/example/src/index.tsx @@ -19,6 +19,7 @@ import RotateInOutComponent from './rotate-in-out'; import RotateScaleFadeInOutComponent from './rotate-scale-fade-in-out'; import AnimTabBarComponent from './anim-tab-bar'; import MarqueeComponent from './marquee'; +import Flow from './flow'; import { isWeb } from './utils'; import { window } from './constants'; import { QRCode } from './components/QRCode'; @@ -39,6 +40,7 @@ export type RootStackParamList = { Parallax: undefined; Stack: undefined; + Flow: undefined; Complex: undefined; AdvancedParallax: undefined; PauseAdvancedParallax: undefined; @@ -113,6 +115,7 @@ function App() { component={ParallaxComponent} /> +