react-native-screen-transitions 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +273 -269
- package/lib/commonjs/__tests__ /geometry.test.js +178 -0
- package/lib/commonjs/__tests__ /geometry.test.js.map +1 -0
- package/lib/commonjs/components/bounds-activator.js +33 -0
- package/lib/commonjs/components/bounds-activator.js.map +1 -0
- package/lib/commonjs/components/controllers/screen-lifecycle.js +66 -0
- package/lib/commonjs/components/controllers/screen-lifecycle.js.map +1 -0
- package/lib/commonjs/components/create-transition-aware-component.js +96 -0
- package/lib/commonjs/components/create-transition-aware-component.js.map +1 -0
- package/lib/commonjs/components/root-transition-aware.js +56 -0
- package/lib/commonjs/components/root-transition-aware.js.map +1 -0
- package/lib/commonjs/configs/index.js +12 -0
- package/lib/commonjs/configs/index.js.map +1 -0
- package/lib/commonjs/configs/presets.js +206 -0
- package/lib/commonjs/configs/presets.js.map +1 -0
- package/lib/commonjs/configs/specs.js +14 -0
- package/lib/commonjs/configs/specs.js.map +1 -0
- package/lib/commonjs/hooks/animation/use-associated-style.js +36 -0
- package/lib/commonjs/hooks/animation/use-associated-style.js.map +1 -0
- package/lib/commonjs/hooks/animation/use-screen-animation.js +120 -0
- package/lib/commonjs/hooks/animation/use-screen-animation.js.map +1 -0
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js +52 -0
- package/lib/commonjs/hooks/bounds/use-bound-measurer.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-build-gestures.js +239 -0
- package/lib/commonjs/hooks/gestures/use-build-gestures.js.map +1 -0
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js +57 -0
- package/lib/commonjs/hooks/gestures/use-scroll-progress.js.map +1 -0
- package/lib/commonjs/hooks/use-stable-callback.js +17 -0
- package/lib/commonjs/hooks/use-stable-callback.js.map +1 -0
- package/lib/commonjs/index.js +37 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js +68 -0
- package/lib/commonjs/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/utils/debounce.js +16 -0
- package/lib/commonjs/integrations/native-stack/utils/debounce.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js +17 -0
- package/lib/commonjs/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/utils/useAnimatedHeaderHeight.js +18 -0
- package/lib/commonjs/integrations/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/utils/useDismissedRouteError.js +22 -0
- package/lib/commonjs/integrations/native-stack/utils/useDismissedRouteError.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js +25 -0
- package/lib/commonjs/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/FontProcessor.js +10 -0
- package/lib/commonjs/integrations/native-stack/views/FontProcessor.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/FontProcessor.native.js +18 -0
- package/lib/commonjs/integrations/native-stack/views/FontProcessor.native.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/FooterComponent.js +17 -0
- package/lib/commonjs/integrations/native-stack/views/FooterComponent.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.js +138 -0
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js +497 -0
- package/lib/commonjs/integrations/native-stack/views/NativeStackView.native.js.map +1 -0
- package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js +203 -0
- package/lib/commonjs/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/providers/gestures.js +64 -0
- package/lib/commonjs/providers/gestures.js.map +1 -0
- package/lib/commonjs/providers/keys.js +35 -0
- package/lib/commonjs/providers/keys.js.map +1 -0
- package/lib/commonjs/stores/animations.js +39 -0
- package/lib/commonjs/stores/animations.js.map +1 -0
- package/lib/commonjs/stores/bounds.js +64 -0
- package/lib/commonjs/stores/bounds.js.map +1 -0
- package/lib/commonjs/stores/gestures.js +38 -0
- package/lib/commonjs/stores/gestures.js.map +1 -0
- package/lib/commonjs/stores/navigator-dismiss-state.js +23 -0
- package/lib/commonjs/stores/navigator-dismiss-state.js.map +1 -0
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js +20 -0
- package/lib/commonjs/stores/utils/reset-stores-for-screen.js.map +1 -0
- package/lib/commonjs/types/animation.js +6 -0
- package/lib/commonjs/types/animation.js.map +1 -0
- package/lib/commonjs/types/bounds.js +6 -0
- package/lib/commonjs/types/bounds.js.map +1 -0
- package/lib/commonjs/types/core.js +6 -0
- package/lib/commonjs/types/core.js.map +1 -0
- package/lib/commonjs/types/gesture.js +2 -0
- package/lib/commonjs/types/gesture.js.map +1 -0
- package/lib/commonjs/types/navigator.js +6 -0
- package/lib/commonjs/types/navigator.js.map +1 -0
- package/lib/commonjs/types/utils.js +2 -0
- package/lib/commonjs/types/utils.js.map +1 -0
- package/lib/commonjs/utils/animation/animate.js +18 -0
- package/lib/commonjs/utils/animation/animate.js.map +1 -0
- package/lib/commonjs/utils/animation/run-transition.js +48 -0
- package/lib/commonjs/utils/animation/run-transition.js.map +1 -0
- package/lib/commonjs/utils/bounds/_types/builder.js +6 -0
- package/lib/commonjs/utils/bounds/_types/builder.js.map +1 -0
- package/lib/commonjs/utils/bounds/_types/geometry.js +2 -0
- package/lib/commonjs/utils/bounds/_types/geometry.js.map +1 -0
- package/lib/commonjs/utils/bounds/_types/get-bounds.js +6 -0
- package/lib/commonjs/utils/bounds/_types/get-bounds.js.map +1 -0
- package/lib/commonjs/utils/bounds/build-bound-styles.js +145 -0
- package/lib/commonjs/utils/bounds/build-bound-styles.js.map +1 -0
- package/lib/commonjs/utils/bounds/constants.js +31 -0
- package/lib/commonjs/utils/bounds/constants.js.map +1 -0
- package/lib/commonjs/utils/bounds/flatten-styles.js +27 -0
- package/lib/commonjs/utils/bounds/flatten-styles.js.map +1 -0
- package/lib/commonjs/utils/bounds/geometry.js +94 -0
- package/lib/commonjs/utils/bounds/geometry.js.map +1 -0
- package/lib/commonjs/utils/bounds/get-bounds.js +51 -0
- package/lib/commonjs/utils/bounds/get-bounds.js.map +1 -0
- package/lib/commonjs/utils/bounds/index.js +38 -0
- package/lib/commonjs/utils/bounds/index.js.map +1 -0
- package/lib/commonjs/utils/bounds/style-composers.js +199 -0
- package/lib/commonjs/utils/bounds/style-composers.js.map +1 -0
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js +81 -0
- package/lib/commonjs/utils/gesture/apply-gesture-activation-criteria.js.map +1 -0
- package/lib/commonjs/utils/gesture/map-gesture-to-progress.js +17 -0
- package/lib/commonjs/utils/gesture/map-gesture-to-progress.js.map +1 -0
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js +21 -0
- package/lib/commonjs/utils/gesture/normalize-gesture-translation.js.map +1 -0
- package/lib/commonjs/utils/index.js +17 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/module/__tests__ /geometry.test.js +178 -0
- package/lib/module/__tests__ /geometry.test.js.map +1 -0
- package/lib/module/components/bounds-activator.js +28 -0
- package/lib/module/components/bounds-activator.js.map +1 -0
- package/lib/module/components/controllers/screen-lifecycle.js +60 -0
- package/lib/module/components/controllers/screen-lifecycle.js.map +1 -0
- package/lib/module/components/create-transition-aware-component.js +91 -0
- package/lib/module/components/create-transition-aware-component.js.map +1 -0
- package/lib/module/components/root-transition-aware.js +51 -0
- package/lib/module/components/root-transition-aware.js.map +1 -0
- package/lib/module/configs/index.js +5 -0
- package/lib/module/configs/index.js.map +1 -0
- package/lib/module/configs/presets.js +197 -0
- package/lib/module/configs/presets.js.map +1 -0
- package/lib/module/configs/specs.js +10 -0
- package/lib/module/configs/specs.js.map +1 -0
- package/lib/module/hooks/animation/use-associated-style.js +32 -0
- package/lib/module/hooks/animation/use-associated-style.js.map +1 -0
- package/lib/module/hooks/animation/use-screen-animation.js +115 -0
- package/lib/module/hooks/animation/use-screen-animation.js.map +1 -0
- package/lib/module/hooks/bounds/use-bound-measurer.js +47 -0
- package/lib/module/hooks/bounds/use-bound-measurer.js.map +1 -0
- package/lib/module/hooks/gestures/use-build-gestures.js +234 -0
- package/lib/module/hooks/gestures/use-build-gestures.js.map +1 -0
- package/lib/module/hooks/gestures/use-scroll-progress.js +52 -0
- package/lib/module/hooks/gestures/use-scroll-progress.js.map +1 -0
- package/lib/module/hooks/use-stable-callback.js +13 -0
- package/lib/module/hooks/use-stable-callback.js.map +1 -0
- package/lib/module/index.js +21 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js +63 -0
- package/lib/module/integrations/native-stack/navigators/createNativeStackNavigator.js.map +1 -0
- package/lib/module/integrations/native-stack/utils/debounce.js +12 -0
- package/lib/module/integrations/native-stack/utils/debounce.js.map +1 -0
- package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js +12 -0
- package/lib/module/integrations/native-stack/utils/getModalRoutesKeys.js.map +1 -0
- package/lib/module/integrations/native-stack/utils/useAnimatedHeaderHeight.js +12 -0
- package/lib/module/integrations/native-stack/utils/useAnimatedHeaderHeight.js.map +1 -0
- package/lib/module/integrations/native-stack/utils/useDismissedRouteError.js +17 -0
- package/lib/module/integrations/native-stack/utils/useDismissedRouteError.js.map +1 -0
- package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js +20 -0
- package/lib/module/integrations/native-stack/utils/useInvalidPreventRemoveError.js.map +1 -0
- package/lib/module/integrations/native-stack/views/FontProcessor.js +6 -0
- package/lib/module/integrations/native-stack/views/FontProcessor.js.map +1 -0
- package/lib/module/integrations/native-stack/views/FontProcessor.native.js +12 -0
- package/lib/module/integrations/native-stack/views/FontProcessor.native.js.map +1 -0
- package/lib/module/integrations/native-stack/views/FooterComponent.js +13 -0
- package/lib/module/integrations/native-stack/views/FooterComponent.js.map +1 -0
- package/lib/module/integrations/native-stack/views/NativeStackView.js +133 -0
- package/lib/module/integrations/native-stack/views/NativeStackView.js.map +1 -0
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js +492 -0
- package/lib/module/integrations/native-stack/views/NativeStackView.native.js.map +1 -0
- package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js +199 -0
- package/lib/module/integrations/native-stack/views/useHeaderConfigProps.js.map +1 -0
- package/lib/module/providers/gestures.js +58 -0
- package/lib/module/providers/gestures.js.map +1 -0
- package/lib/module/providers/keys.js +29 -0
- package/lib/module/providers/keys.js.map +1 -0
- package/lib/module/stores/animations.js +33 -0
- package/lib/module/stores/animations.js.map +1 -0
- package/lib/module/stores/bounds.js +60 -0
- package/lib/module/stores/bounds.js.map +1 -0
- package/lib/module/stores/gestures.js +34 -0
- package/lib/module/stores/gestures.js.map +1 -0
- package/lib/module/stores/navigator-dismiss-state.js +19 -0
- package/lib/module/stores/navigator-dismiss-state.js.map +1 -0
- package/lib/module/stores/utils/reset-stores-for-screen.js +16 -0
- package/lib/module/stores/utils/reset-stores-for-screen.js.map +1 -0
- package/lib/module/types/animation.js +4 -0
- package/lib/module/types/animation.js.map +1 -0
- package/lib/module/types/bounds.js +4 -0
- package/lib/module/types/bounds.js.map +1 -0
- package/lib/module/types/core.js +4 -0
- package/lib/module/types/core.js.map +1 -0
- package/lib/module/types/gesture.js +2 -0
- package/lib/module/types/gesture.js.map +1 -0
- package/lib/module/types/navigator.js +4 -0
- package/lib/module/types/navigator.js.map +1 -0
- package/lib/module/types/utils.js +2 -0
- package/lib/module/types/utils.js.map +1 -0
- package/lib/module/utils/animation/animate.js +13 -0
- package/lib/module/utils/animation/animate.js.map +1 -0
- package/lib/module/utils/animation/run-transition.js +43 -0
- package/lib/module/utils/animation/run-transition.js.map +1 -0
- package/lib/module/utils/bounds/_types/builder.js +4 -0
- package/lib/module/utils/bounds/_types/builder.js.map +1 -0
- package/lib/module/utils/bounds/_types/geometry.js +2 -0
- package/lib/module/utils/bounds/_types/geometry.js.map +1 -0
- package/lib/module/utils/bounds/_types/get-bounds.js +4 -0
- package/lib/module/utils/bounds/_types/get-bounds.js.map +1 -0
- package/lib/module/utils/bounds/build-bound-styles.js +141 -0
- package/lib/module/utils/bounds/build-bound-styles.js.map +1 -0
- package/lib/module/utils/bounds/constants.js +26 -0
- package/lib/module/utils/bounds/constants.js.map +1 -0
- package/lib/module/utils/bounds/flatten-styles.js +23 -0
- package/lib/module/utils/bounds/flatten-styles.js.map +1 -0
- package/lib/module/utils/bounds/geometry.js +89 -0
- package/lib/module/utils/bounds/geometry.js.map +1 -0
- package/lib/module/utils/bounds/get-bounds.js +46 -0
- package/lib/module/utils/bounds/get-bounds.js.map +1 -0
- package/lib/module/utils/bounds/index.js +33 -0
- package/lib/module/utils/bounds/index.js.map +1 -0
- package/lib/module/utils/bounds/style-composers.js +191 -0
- package/lib/module/utils/bounds/style-composers.js.map +1 -0
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js +76 -0
- package/lib/module/utils/gesture/apply-gesture-activation-criteria.js.map +1 -0
- package/lib/module/utils/gesture/map-gesture-to-progress.js +12 -0
- package/lib/module/utils/gesture/map-gesture-to-progress.js.map +1 -0
- package/lib/module/utils/gesture/normalize-gesture-translation.js +16 -0
- package/lib/module/utils/gesture/normalize-gesture-translation.js.map +1 -0
- package/lib/module/utils/index.js +4 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/typescript/components/bounds-activator.d.ts +8 -0
- package/lib/typescript/components/bounds-activator.d.ts.map +1 -0
- package/lib/typescript/components/controllers/screen-lifecycle.d.ts +6 -0
- package/lib/typescript/components/controllers/screen-lifecycle.d.ts.map +1 -0
- package/lib/typescript/components/create-transition-aware-component.d.ts +9 -0
- package/lib/typescript/components/create-transition-aware-component.d.ts.map +1 -0
- package/lib/typescript/components/root-transition-aware.d.ts +6 -0
- package/lib/typescript/components/root-transition-aware.d.ts.map +1 -0
- package/lib/typescript/configs/index.d.ts +3 -0
- package/lib/typescript/configs/index.d.ts.map +1 -0
- package/lib/typescript/configs/presets.d.ts +9 -0
- package/lib/typescript/configs/presets.d.ts.map +1 -0
- package/lib/typescript/configs/specs.d.ts +3 -0
- package/lib/typescript/configs/specs.d.ts.map +1 -0
- package/lib/typescript/hooks/animation/use-associated-style.d.ts +11 -0
- package/lib/typescript/hooks/animation/use-associated-style.d.ts.map +1 -0
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts +7 -0
- package/lib/typescript/hooks/animation/use-screen-animation.d.ts.map +1 -0
- package/lib/typescript/hooks/bounds/use-bound-measurer.d.ts +18 -0
- package/lib/typescript/hooks/bounds/use-bound-measurer.d.ts.map +1 -0
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts +11 -0
- package/lib/typescript/hooks/gestures/use-build-gestures.d.ts.map +1 -0
- package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts +14 -0
- package/lib/typescript/hooks/gestures/use-scroll-progress.d.ts.map +1 -0
- package/lib/typescript/hooks/use-stable-callback.d.ts +2 -0
- package/lib/typescript/hooks/use-stable-callback.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1275 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts +16 -0
- package/lib/typescript/integrations/native-stack/navigators/createNativeStackNavigator.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/utils/debounce.d.ts +2 -0
- package/lib/typescript/integrations/native-stack/utils/debounce.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts +4 -0
- package/lib/typescript/integrations/native-stack/utils/getModalRoutesKeys.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/utils/useAnimatedHeaderHeight.d.ts +5 -0
- package/lib/typescript/integrations/native-stack/utils/useAnimatedHeaderHeight.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/utils/useDismissedRouteError.d.ts +6 -0
- package/lib/typescript/integrations/native-stack/utils/useDismissedRouteError.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts +3 -0
- package/lib/typescript/integrations/native-stack/utils/useInvalidPreventRemoveError.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/FontProcessor.d.ts +2 -0
- package/lib/typescript/integrations/native-stack/views/FontProcessor.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/FontProcessor.native.d.ts +2 -0
- package/lib/typescript/integrations/native-stack/views/FontProcessor.native.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/FooterComponent.d.ts +7 -0
- package/lib/typescript/integrations/native-stack/views/FooterComponent.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts +11 -0
- package/lib/typescript/integrations/native-stack/views/NativeStackView.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts +11 -0
- package/lib/typescript/integrations/native-stack/views/NativeStackView.native.d.ts.map +1 -0
- package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts +44 -0
- package/lib/typescript/integrations/native-stack/views/useHeaderConfigProps.d.ts.map +1 -0
- package/lib/typescript/providers/gestures.d.ts +22 -0
- package/lib/typescript/providers/gestures.d.ts.map +1 -0
- package/lib/typescript/providers/keys.d.ts +16 -0
- package/lib/typescript/providers/keys.d.ts.map +1 -0
- package/lib/typescript/stores/animations.d.ts +17 -0
- package/lib/typescript/stores/animations.d.ts.map +1 -0
- package/lib/typescript/stores/bounds.d.ts +21 -0
- package/lib/typescript/stores/bounds.d.ts.map +1 -0
- package/lib/typescript/stores/gestures.d.ts +21 -0
- package/lib/typescript/stores/gestures.d.ts.map +1 -0
- package/lib/typescript/stores/navigator-dismiss-state.d.ts +7 -0
- package/lib/typescript/stores/navigator-dismiss-state.d.ts.map +1 -0
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts +6 -0
- package/lib/typescript/stores/utils/reset-stores-for-screen.d.ts.map +1 -0
- package/lib/typescript/types/animation.d.ts +65 -0
- package/lib/typescript/types/animation.d.ts.map +1 -0
- package/lib/typescript/types/bounds.d.ts +73 -0
- package/lib/typescript/types/bounds.d.ts.map +1 -0
- package/lib/typescript/types/core.d.ts +47 -0
- package/lib/typescript/types/core.d.ts.map +1 -0
- package/lib/typescript/types/gesture.d.ts +28 -0
- package/lib/typescript/types/gesture.d.ts.map +1 -0
- package/lib/typescript/types/navigator.d.ts +683 -0
- package/lib/typescript/types/navigator.d.ts.map +1 -0
- package/lib/typescript/types/utils.d.ts +5 -0
- package/lib/typescript/types/utils.d.ts.map +1 -0
- package/lib/typescript/utils/animation/animate.d.ts +4 -0
- package/lib/typescript/utils/animation/animate.d.ts.map +1 -0
- package/lib/typescript/utils/animation/run-transition.d.ts +11 -0
- package/lib/typescript/utils/animation/run-transition.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_types/builder.d.ts +36 -0
- package/lib/typescript/utils/bounds/_types/builder.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_types/geometry.d.ts +16 -0
- package/lib/typescript/utils/bounds/_types/geometry.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/_types/get-bounds.d.ts +10 -0
- package/lib/typescript/utils/bounds/_types/get-bounds.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts +4 -0
- package/lib/typescript/utils/bounds/build-bound-styles.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/constants.d.ts +7 -0
- package/lib/typescript/utils/bounds/constants.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/flatten-styles.d.ts +2 -0
- package/lib/typescript/utils/bounds/flatten-styles.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/geometry.d.ts +24 -0
- package/lib/typescript/utils/bounds/geometry.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/get-bounds.d.ts +4 -0
- package/lib/typescript/utils/bounds/get-bounds.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/index.d.ts +15 -0
- package/lib/typescript/utils/bounds/index.d.ts.map +1 -0
- package/lib/typescript/utils/bounds/style-composers.d.ts +40 -0
- package/lib/typescript/utils/bounds/style-composers.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts +17 -0
- package/lib/typescript/utils/gesture/apply-gesture-activation-criteria.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/map-gesture-to-progress.d.ts +5 -0
- package/lib/typescript/utils/gesture/map-gesture-to-progress.d.ts.map +1 -0
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts +6 -0
- package/lib/typescript/utils/gesture/normalize-gesture-translation.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +2 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/package.json +33 -16
- package/dist/index.d.mts +0 -1473
- package/dist/index.d.ts +0 -1473
- package/dist/index.js +0 -1169
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1159
- package/dist/index.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
# react-native-screen-transitions
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
| iOS | Android |
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
|---|---|
|
|
5
|
+
| <video src="https://github.com/user-attachments/assets/81f39391-80c0-4ce4-b6ff-76de85d2cf03" width="300" height="600" controls></video> | <video src="https://github.com/user-attachments/assets/c2b4c6ca-2b0c-4cf4-a164-f7e68cee0c32" width="300" controls></video> |
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
**WIP**: This package is a work-in-progress. It provides customizable screen transition animations for React Native apps, primarily designed for use with `expo-router` and `react-navigation`. It supports gestures, predefined presets, and custom animations, making it easy to add polished transitions to your navigation flows.
|
|
10
9
|
|
|
11
|
-
This library is inspired by the transition system in `@react-navigation/stack` (not the native stack). If you're familiar with how transitions work there (e.g., using interpolators), you'll find this similar.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
## Features
|
|
17
|
-
- Predefined animation presets (e.g., SlideFromTop, ZoomIn, DraggableCard).
|
|
18
|
-
- Gesture support for interactive transitions (e.g., drag-to-dismiss).
|
|
19
|
-
- Animations using Reanimated.
|
|
20
|
-
- Easy integration with expo-router and react-navigation.
|
|
21
|
-
|
|
22
10
|
## Compatibility
|
|
23
11
|
- **Platforms**: Currently tested on iOS and Android. Not tested or intended for web—web support is not a priority and may not work due to gesture and animation differences.
|
|
24
12
|
- **Dependencies**: Requires React Native, Reanimated, Gesture Handler, and either expo-router or react-navigation.
|
|
@@ -34,236 +22,170 @@ bun add react-native-screen-transitions
|
|
|
34
22
|
|
|
35
23
|
## Peer Dependencies
|
|
36
24
|
```bash
|
|
37
|
-
npm install react-native-reanimated react-native-gesture-handler
|
|
25
|
+
npm install react-native-reanimated react-native-gesture-handler \
|
|
26
|
+
@react-navigation/native @react-navigation/native-stack \
|
|
27
|
+
@react-navigation/elements react-native-screens \
|
|
28
|
+
react-native-safe-area-context
|
|
38
29
|
```
|
|
39
30
|
|
|
40
|
-
##
|
|
41
|
-
|
|
42
|
-
Getting started with screen transitions is simple. Here's how to add your first animated transition:
|
|
31
|
+
## Setup
|
|
43
32
|
|
|
44
|
-
### 1.
|
|
33
|
+
### 1. Expo Router
|
|
45
34
|
|
|
46
35
|
```tsx
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
36
|
+
import type {
|
|
37
|
+
ParamListBase,
|
|
38
|
+
StackNavigationState,
|
|
39
|
+
} from "@react-navigation/native";
|
|
40
|
+
import { withLayoutContext } from "expo-router";
|
|
41
|
+
import {
|
|
42
|
+
createNativeStackNavigator,
|
|
43
|
+
type NativeStackNavigationEventMap,
|
|
44
|
+
type NativeStackNavigationOptions,
|
|
45
|
+
} from "react-native-screen-transitions";
|
|
46
|
+
|
|
47
|
+
const { Navigator } = createNativeStackNavigator();
|
|
48
|
+
|
|
49
|
+
export const Stack = withLayoutContext<
|
|
50
|
+
NativeStackNavigationOptions,
|
|
51
|
+
typeof Navigator,
|
|
52
|
+
StackNavigationState<ParamListBase>,
|
|
53
|
+
NativeStackNavigationEventMap
|
|
54
|
+
>(Navigator);
|
|
58
55
|
```
|
|
59
56
|
|
|
60
|
-
|
|
57
|
+
That’s it — you’re ready to go.
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
import { Stack } from "expo-router";
|
|
64
|
-
import Transition from "react-native-screen-transitions";
|
|
59
|
+
### 2. React Navigation (bare)
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<GestureHandlerRootView>
|
|
69
|
-
<Stack>
|
|
70
|
-
<Stack.Screen
|
|
71
|
-
name="a"
|
|
72
|
-
options={{ headerShown: false }}
|
|
73
|
-
{...Transition.createScreenConfig()}
|
|
74
|
-
/>
|
|
75
|
-
<Stack.Screen
|
|
76
|
-
name="b"
|
|
77
|
-
{...Transition.createScreenConfig({
|
|
78
|
-
...Transition.presets.SlideFromTop(),
|
|
79
|
-
})}
|
|
80
|
-
/>
|
|
81
|
-
</Stack>
|
|
82
|
-
</GestureHandlerRootView>
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
```
|
|
61
|
+
If you’re using **React Navigation** directly (not Expo Router), the navigator is already configured.
|
|
62
|
+
No extra setup is required—just import and use as usual:
|
|
86
63
|
|
|
87
|
-
|
|
64
|
+
```tsx
|
|
65
|
+
import { createNativeStackNavigator } from 'react-native-screen-transitions';
|
|
88
66
|
|
|
89
|
-
|
|
67
|
+
const Stack = createNativeStackNavigator();
|
|
90
68
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
import Transition from "react-native-screen-transitions";
|
|
69
|
+
// Use Stack.Navigator and Stack.Screen as normal
|
|
70
|
+
```
|
|
94
71
|
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<Transition.View> {/* By default has flex: 1 */}
|
|
98
|
-
{/* Your content */}
|
|
99
|
-
</Transition.View>
|
|
100
|
-
);
|
|
101
|
-
}
|
|
72
|
+
### Extended native-stack options
|
|
102
73
|
|
|
103
|
-
|
|
104
|
-
|
|
74
|
+
This package ships an **extended native stack** built on top of React Navigation’s native stack.
|
|
75
|
+
All the usual native-stack options are available, plus the following extras:
|
|
105
76
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
77
|
+
| Option | Type | Description |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| `enableTransitions` | `boolean` | Switches the screen to a transparent modal and disables the header so custom transitions can take over. |
|
|
80
|
+
| `screenStyleInterpolator` | `ScreenStyleInterpolator` | Function that returns animated styles based on transition progress. |
|
|
81
|
+
| `transitionSpec` | `TransitionSpec` | Reanimated timing/spring config for open/close animations. |
|
|
82
|
+
| `gestureEnabled` | `boolean` | Whether swipe-to-dismiss is allowed. |
|
|
83
|
+
| `gestureDirection` | `GestureDirection \| GestureDirection[]` | Allowed swipe directions (`vertical`, `horizontal`, etc.). |
|
|
84
|
+
| `gestureVelocityImpact` | `number` | How much the gesture’s velocity affects dismissal. |
|
|
85
|
+
| `gestureResponseDistance` | `number` | Distance from screen where the gesture is recognized. |
|
|
86
|
+
| `gestureDrivesProgress` | `boolean` | Whether the gesture directly drives the transition progress. |
|
|
114
87
|
|
|
115
|
-
###
|
|
88
|
+
### Renamed native options (extended stack)
|
|
116
89
|
|
|
117
|
-
|
|
90
|
+
To avoid collisions with the new options above, the built-in React Navigation gesture props are renamed:
|
|
118
91
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
92
|
+
| React Navigation prop | Renamed to |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `gestureDirection` | `nativeGestureDirection` |
|
|
95
|
+
| `gestureEnabled` | `nativeGestureEnabled` |
|
|
96
|
+
| `gestureResponseDistance` | `nativeGestureResponseDistance` |
|
|
122
97
|
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<Transition.View>
|
|
126
|
-
<Stack>
|
|
127
|
-
<Stack.Screen name="nested-a" {...Transition.createScreenConfig()} />
|
|
128
|
-
<Stack.Screen name="nested-b" {...Transition.createScreenConfig()} />
|
|
129
|
-
</Stack>
|
|
130
|
-
</Transition.View>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
```
|
|
98
|
+
All other React Navigation native-stack options keep their original names.
|
|
134
99
|
|
|
135
|
-
## Advanced Usage
|
|
136
100
|
|
|
137
|
-
|
|
101
|
+
## Creating your screen animations
|
|
138
102
|
|
|
139
|
-
|
|
103
|
+
### Using presets
|
|
140
104
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
import { Stack } from "expo-router";
|
|
144
|
-
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
145
|
-
import Transition from "react-native-screen-transitions";
|
|
146
|
-
import { interpolate, Easing } from "react-native-reanimated";
|
|
105
|
+
Pick a built-in preset and spread it into the screen’s options.
|
|
106
|
+
The incoming screen automatically controls the previous screen.
|
|
147
107
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
layouts: { screen: { width } },
|
|
167
|
-
}) => {
|
|
168
|
-
"worklet";
|
|
169
|
-
// Mimics the iOS stack slide animation
|
|
170
|
-
const progress = current.progress.value + (next?.progress.value || 0);
|
|
171
|
-
const translateX = interpolate(
|
|
172
|
-
progress,
|
|
173
|
-
[0, 1, 2],
|
|
174
|
-
[width, 0, width * -0.3],
|
|
175
|
-
"clamp"
|
|
176
|
-
);
|
|
177
|
-
return {
|
|
178
|
-
contentStyle: {
|
|
179
|
-
transform: [{ translateX }],
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
},
|
|
183
|
-
transitionSpec: {
|
|
184
|
-
open: {
|
|
185
|
-
easing: Easing.bezier(0.25, 0.1, 0.25, 1.0),
|
|
186
|
-
duration: 1000,
|
|
187
|
-
},
|
|
188
|
-
close: {
|
|
189
|
-
damping: 10,
|
|
190
|
-
mass: 0.5,
|
|
191
|
-
stiffness: 100,
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
})}
|
|
195
|
-
/>
|
|
196
|
-
</Stack>
|
|
197
|
-
</GestureHandlerRootView>
|
|
198
|
-
);
|
|
199
|
-
}
|
|
108
|
+
```tsx
|
|
109
|
+
<Stack>
|
|
110
|
+
<Stack.Screen
|
|
111
|
+
name="a"
|
|
112
|
+
/>
|
|
113
|
+
<Stack.Screen
|
|
114
|
+
name="b"
|
|
115
|
+
options={{
|
|
116
|
+
...Transition.presets.SlideFromTop(),
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
<Stack.Screen
|
|
120
|
+
name="c"
|
|
121
|
+
options={{
|
|
122
|
+
...Transition.presets.SlideFromBottom(),
|
|
123
|
+
}}
|
|
124
|
+
/>
|
|
125
|
+
</Stack>
|
|
200
126
|
```
|
|
201
127
|
|
|
202
|
-
|
|
128
|
+
### Navigator-level custom animations
|
|
203
129
|
|
|
204
|
-
|
|
130
|
+
Instead of presets, you can define a custom transition directly on the screen’s options.
|
|
131
|
+
`screenStyleInterpolator` receives an object with the following useful fields:
|
|
132
|
+
|
|
133
|
+
- `progress` – overall transition progress (`0 → 2`).
|
|
134
|
+
- `current` – state for the current screen (includes `progress`, `closing`, `gesture`, `route`, etc.).
|
|
135
|
+
- `previous` – state for the previous screen (may be `undefined`).
|
|
136
|
+
- `next` – state for the next screen (may be `undefined`).
|
|
137
|
+
- `layouts.screen` – `{ width, height }` of the container.
|
|
138
|
+
- `insets` – `{ top, right, bottom, left }` safe-area insets.
|
|
139
|
+
- `bounds(id)` – helper to compute shared-element transforms (see IntelliSense for chainable methods).
|
|
140
|
+
- `activeBoundId` – id of the active bound.
|
|
141
|
+
- `focused` – state of the current screen
|
|
205
142
|
|
|
206
|
-
Alternatively, define animations at the screen level using the `useScreenAnimation` hook. This is useful for screen-specific effects or when you don't need to animate both screens. You CAN combine this with `screenStyleInterpolator` for more advanced animations, but for this example, we'll leave `screenStyleInterpolator` undefined.
|
|
207
143
|
|
|
208
144
|
```tsx
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
name="a"
|
|
212
|
-
{...Transition.createScreenConfig()}
|
|
213
|
-
/>
|
|
145
|
+
import { interpolate } from 'react-native-reanimated'
|
|
146
|
+
|
|
214
147
|
<Stack.Screen
|
|
215
148
|
name="b"
|
|
216
|
-
{
|
|
149
|
+
options={{
|
|
150
|
+
enableTransitions: true,
|
|
151
|
+
screenStyleInterpolator: ({
|
|
152
|
+
layouts: { screen: { width } },
|
|
153
|
+
progress,
|
|
154
|
+
}) => {
|
|
155
|
+
"worklet";
|
|
156
|
+
|
|
157
|
+
const x = interpolate(progress, [0, 1, 2], [width, 0, -width]);
|
|
158
|
+
return {
|
|
159
|
+
contentStyle: {
|
|
160
|
+
transform: [{ translateX: x }],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
},
|
|
217
164
|
transitionSpec: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
duration: 1000,
|
|
221
|
-
},
|
|
222
|
-
close: {
|
|
223
|
-
damping: 10,
|
|
224
|
-
mass: 0.5,
|
|
225
|
-
stiffness: 100,
|
|
226
|
-
},
|
|
165
|
+
close: Transition.specs.DefaultSpec,
|
|
166
|
+
open: Transition.specs.DefaultSpec,
|
|
227
167
|
},
|
|
228
|
-
}
|
|
168
|
+
}}
|
|
229
169
|
/>
|
|
230
170
|
```
|
|
231
171
|
|
|
232
|
-
|
|
233
|
-
// a.tsx (previous screen)
|
|
234
|
-
import { useScreenAnimation } from 'react-native-screen-transitions';
|
|
235
|
-
import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
|
|
236
|
-
|
|
237
|
-
export default function A() {
|
|
238
|
-
const { next, layouts: { screen: { width } } } = useScreenAnimation();
|
|
172
|
+
In this example the incoming screen slides in from the right while the exiting screen slides out to the left.
|
|
239
173
|
|
|
240
|
-
|
|
241
|
-
// Unfocusing animation - screen slides left when next screen enters
|
|
242
|
-
const translateX = interpolate(next?.progress.value || 0, [0, 1], [0, width * -0.3]);
|
|
243
|
-
return {
|
|
244
|
-
transform: [{ translateX }],
|
|
245
|
-
};
|
|
246
|
-
});
|
|
174
|
+
### Screen-level custom animations with `useScreenAnimation`
|
|
247
175
|
|
|
248
|
-
|
|
249
|
-
<Animated.View style={[{ flex: 1 }, animatedStyle]}>
|
|
250
|
-
{/* Your content */}
|
|
251
|
-
</Animated.View>
|
|
252
|
-
);
|
|
253
|
-
}
|
|
176
|
+
For per-screen control, import the `useScreenAnimation` hook and compose your own animated styles.
|
|
254
177
|
|
|
255
|
-
|
|
178
|
+
```tsx
|
|
256
179
|
import { useScreenAnimation } from 'react-native-screen-transitions';
|
|
257
180
|
import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
|
|
258
181
|
|
|
259
|
-
export default function
|
|
260
|
-
const
|
|
182
|
+
export default function BScreen() {
|
|
183
|
+
const props = useScreenAnimation();
|
|
261
184
|
|
|
262
185
|
const animatedStyle = useAnimatedStyle(() => {
|
|
263
|
-
|
|
264
|
-
const translateX = interpolate(current.progress.value, [0, 1], [width, 0]);
|
|
186
|
+
const { current: { progress } } = props.value
|
|
265
187
|
return {
|
|
266
|
-
|
|
188
|
+
opacity: progress
|
|
267
189
|
};
|
|
268
190
|
});
|
|
269
191
|
|
|
@@ -275,115 +197,193 @@ export default function B() {
|
|
|
275
197
|
}
|
|
276
198
|
```
|
|
277
199
|
|
|
200
|
+
## Swipe-to-dismiss with scrollables
|
|
278
201
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
Screen transitions can be dismissed based on defined gesture directions. Integration with scrollable components is seamless:
|
|
283
|
-
|
|
284
|
-
### Create Custom Transition-Aware Scrollables
|
|
285
|
-
|
|
286
|
-
You can use built-in scrollables or create your own
|
|
202
|
+
You can drag a screen away even when it contains a scroll view.
|
|
203
|
+
Just swap the regular scrollable for a transition-aware one:
|
|
287
204
|
|
|
288
205
|
```tsx
|
|
206
|
+
import Transition from 'react-native-screen-transitions';
|
|
207
|
+
import { LegendList } from "@legendapp/list"
|
|
289
208
|
import { FlashList } from "@shopify/flash-list";
|
|
290
|
-
import { LegendList } from "@legendapp/list";
|
|
291
|
-
import { FlatList, ScrollView } from "react-native";
|
|
292
|
-
import Transition from "react-native-screen-transitions";
|
|
293
209
|
|
|
294
|
-
//
|
|
295
|
-
const
|
|
296
|
-
const
|
|
210
|
+
// Drop-in replacements
|
|
211
|
+
const ScrollView = Transition.ScrollView;
|
|
212
|
+
const FlatList = Transition.FlatList;
|
|
297
213
|
|
|
298
|
-
//
|
|
299
|
-
const TransitionFlashList =
|
|
300
|
-
|
|
301
|
-
```
|
|
214
|
+
// Or wrap any list you like
|
|
215
|
+
const TransitionFlashList =
|
|
216
|
+
Transition.createTransitionAwareScrollable(FlashList, { isScrollable: true });
|
|
302
217
|
|
|
303
|
-
|
|
218
|
+
const TransitionLegendList =
|
|
219
|
+
Transition.createTransitionAwareScrollable(LegendList, { isScrollable: true} );
|
|
220
|
+
```
|
|
304
221
|
|
|
305
|
-
|
|
222
|
+
Enable the gesture on the screen:
|
|
306
223
|
|
|
307
224
|
```tsx
|
|
308
225
|
<Stack.Screen
|
|
309
|
-
name="
|
|
310
|
-
{
|
|
311
|
-
|
|
226
|
+
name="gallery"
|
|
227
|
+
options={{
|
|
228
|
+
enableTransitions: true,
|
|
312
229
|
gestureEnabled: true,
|
|
313
|
-
//
|
|
314
|
-
}
|
|
230
|
+
gestureDirection: 'vertical', // or 'horizontal', ['vertical', 'horizontal'], etc.
|
|
231
|
+
}}
|
|
315
232
|
/>
|
|
316
233
|
```
|
|
317
234
|
|
|
318
|
-
|
|
235
|
+
Use it in the screen:
|
|
319
236
|
|
|
320
237
|
```tsx
|
|
321
|
-
|
|
322
|
-
export default function ScrollableScreen() {
|
|
238
|
+
export default function B() {
|
|
323
239
|
return (
|
|
324
240
|
<Transition.ScrollView>
|
|
325
|
-
{/*
|
|
241
|
+
{/* content */}
|
|
326
242
|
</Transition.ScrollView>
|
|
327
243
|
);
|
|
328
244
|
}
|
|
329
245
|
```
|
|
330
246
|
|
|
331
|
-
|
|
332
|
-
- `vertical`: ScrollView is at the top (scrollY <= 0)
|
|
333
|
-
- `vertical-inverted`: ScrollView is at the bottom (scrollY >= maxScroll)
|
|
334
|
-
- `horizontal`: ScrollView is at the left edge
|
|
335
|
-
- `horizontal-inverted`: ScrollView is at the right edge
|
|
247
|
+
Gesture rules (handled automatically):
|
|
336
248
|
|
|
337
|
-
|
|
249
|
+
- **vertical** – only starts when the list is at the very top
|
|
250
|
+
- **vertical-inverted** – only starts when the list is at the very bottom
|
|
251
|
+
- **horizontal** / **horizontal-inverted** – only starts when the list is at the left or right edge
|
|
338
252
|
|
|
339
|
-
|
|
253
|
+
These rules apply **only when the screen contains a scrollable**.
|
|
254
|
+
If no scroll view is present, the gesture can begin from **anywhere on the screen**—not restricted to the edges.
|
|
340
255
|
|
|
341
|
-
|
|
256
|
+
## Bounds (measure-driven screen transitions)
|
|
342
257
|
|
|
343
|
-
|
|
344
|
-
|
|
258
|
+
Bounds let you animate **any component** between two screens by measuring its start and end positions.
|
|
259
|
+
They are **not shared elements**—they’re just measurements.
|
|
260
|
+
Tag the component you want to animate with `sharedBoundTag`, then describe how it should move when the screen transition starts.
|
|
345
261
|
|
|
346
|
-
|
|
347
|
-
Prioritize transform and opacity properties over layout-affecting properties for the smoothest animations:
|
|
262
|
+
1. Tag the source component
|
|
348
263
|
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
264
|
+
```tsx
|
|
265
|
+
<Transition.View sharedBoundTag="hero" style={{ width: 100, height: 100 }}>
|
|
266
|
+
<Image source={uri} style={{ width: '100%', height: '100%' }} resizeMode="cover" />
|
|
267
|
+
</Transition.View>
|
|
268
|
+
```
|
|
353
269
|
|
|
354
|
-
|
|
355
|
-
- Layout properties (`width`, `height`, `padding`, `margin`)
|
|
356
|
-
- `borderRadius` on large elements
|
|
357
|
-
- Complex `shadowOffset` or `elevation` changes
|
|
358
|
-
- Frequent `zIndex` modifications
|
|
270
|
+
2. Tag the destination component (same id)
|
|
359
271
|
|
|
360
|
-
|
|
272
|
+
```tsx
|
|
273
|
+
<Transition.View sharedBoundTag="hero" style={{ width: 200, height: 200 }}>
|
|
274
|
+
<Image source={uri} style={{ width: '100%', height: '100%' }} resizeMode="cover" />
|
|
275
|
+
</Transition.View>
|
|
276
|
+
```
|
|
361
277
|
|
|
362
|
-
|
|
278
|
+
3. Drive the animation in `screenStyleInterpolator`
|
|
363
279
|
|
|
364
280
|
```tsx
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
281
|
+
screenStyleInterpolator: ({
|
|
282
|
+
activeBoundId,
|
|
283
|
+
bounds,
|
|
284
|
+
focused,
|
|
285
|
+
current,
|
|
286
|
+
next,
|
|
287
|
+
}) => {
|
|
288
|
+
"worklet";
|
|
289
|
+
|
|
290
|
+
const animatedBoundStyles = bounds()
|
|
291
|
+
.relative()
|
|
292
|
+
.transform()
|
|
293
|
+
.build();
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
[activeBoundId]: animatedBoundStyles,
|
|
297
|
+
};
|
|
298
|
+
};
|
|
299
|
+
```
|
|
376
300
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
301
|
+
That’s it—the bounds helper works alongside focused and unfocused screens.
|
|
302
|
+
For further customization, separate logic by the `focused` prop:
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
screenStyleInterpolator: ({
|
|
306
|
+
activeBoundId,
|
|
307
|
+
bounds,
|
|
308
|
+
focused,
|
|
309
|
+
current,
|
|
310
|
+
next,
|
|
311
|
+
}) => {
|
|
312
|
+
"worklet";
|
|
313
|
+
|
|
314
|
+
|
|
315
|
+
if (focused) {
|
|
316
|
+
const focusedBoundStyles = bounds()
|
|
317
|
+
.relative()
|
|
318
|
+
.transform()
|
|
319
|
+
.build();
|
|
320
|
+
|
|
321
|
+
return {
|
|
322
|
+
[activeBoundId]: focusedBoundStyles,
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
return {}
|
|
327
|
+
};
|
|
384
328
|
```
|
|
385
329
|
|
|
386
|
-
|
|
330
|
+
|
|
331
|
+
### Choosing the right modifier
|
|
332
|
+
|
|
333
|
+
| Modifier | When to use |
|
|
334
|
+
|---|---|
|
|
335
|
+
| `gestures({x,y})` | Sync the bound with live gesture deltas (drag, swipe). |
|
|
336
|
+
| `toFullscreen()` | Destination has no `sharedBoundTag`; animate to full-screen size. |
|
|
337
|
+
| `absolute()` | Element is not constrained by parent layout (uses pageX/pageY). |
|
|
338
|
+
| `relative()` | Element is inside layout constraints (default). |
|
|
339
|
+
| `transform()` | Animate with `translateX/Y` + `scaleX/Y` (default). |
|
|
340
|
+
| `size()` | Animate `translateX/Y` + `width/height` (no scale). |
|
|
341
|
+
| `content()` | Center the container so its bound aligns with the source at progress start. |
|
|
342
|
+
| `contentFill()` / `contentFit()` | Control how the content scales inside the container. |
|
|
343
|
+
| `build()` | Finalize the animated style object. |
|
|
344
|
+
|
|
345
|
+
### Quick access: `bounds.get()`
|
|
346
|
+
|
|
347
|
+
Need the raw measurements or styles for a specific bound?
|
|
348
|
+
Call `bounds.get(boundId, phase)` to retrieve the exact dimensions and style object for any bound tag and screen phase (`current`, `next`, or `previous`).
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
const heroMetrics = bounds.get('hero', 'current');
|
|
352
|
+
// heroMetrics = { bounds: { x, y, width, height, pageX, pageY }, styles: { ... } }
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Use this when you want explicit control over which bound’s data you animate, regardless of the current screen focus.
|
|
356
|
+
|
|
357
|
+
### Animating individual components with `styleId`
|
|
358
|
+
|
|
359
|
+
Use `styleId` to animate a single view inside a screen.
|
|
360
|
+
|
|
361
|
+
1. Tag the element:
|
|
362
|
+
|
|
363
|
+
```tsx
|
|
364
|
+
<Transition.View styleId="fade-box" style={{ width: 100, height: 100, backgroundColor: 'crimson' }} />
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
2. Drive it from the interpolator:
|
|
368
|
+
|
|
369
|
+
```tsx
|
|
370
|
+
screenStyleInterpolator: ({ progress }) => {
|
|
371
|
+
"worklet";
|
|
372
|
+
|
|
373
|
+
return {
|
|
374
|
+
'fade-box': {
|
|
375
|
+
opacity: interpolate(progress, [0, 1, 2],[0, 1, 0])
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
};
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
The red square fades in as the screen opens.
|
|
382
|
+
|
|
383
|
+
## Known Issues
|
|
384
|
+
|
|
385
|
+
- **Delayed Touch Events** – There’s a noticeable delay in touch events, likely caused by the `beforeRemove` listener in the native stack. If this affects your app, please hold off on using this package until a fix is available.
|
|
386
|
+
- **Deeply nested navigators with scrollables** – Behavior is currently unstable. We recommend using programmatic dismissal for deeply nested navigators that contain scrollables, as the gesture-driven dismissal logic needs an overhaul.
|
|
387
387
|
|
|
388
388
|
|
|
389
389
|
## Support and Development
|
|
@@ -395,6 +395,10 @@ This package is provided as-is and is developed in my free time. While I strive
|
|
|
395
395
|
|
|
396
396
|
I apologize for any inconvenience this may cause. If you encounter issues or have suggestions, please feel free to open an issue on the repository.
|
|
397
397
|
|
|
398
|
+
### Support the project
|
|
399
|
+
I’ve estimated I downed around 60 cups of coffee while building this.
|
|
400
|
+
If you’d like to fuel the next release, [buy me a coffee](https://buymeacoffee.com/trpfsu)
|
|
401
|
+
|
|
398
402
|
|
|
399
403
|
|
|
400
404
|
## License
|