react-native-header-motion 1.0.0-alpha.0 → 1.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/README.md +65 -528
- package/lib/module/components/Bridge.js +16 -0
- package/lib/module/components/Bridge.js.map +1 -0
- package/lib/module/components/FlatList.js +5 -54
- package/lib/module/components/FlatList.js.map +1 -1
- package/lib/module/components/Header.js +71 -13
- package/lib/module/components/Header.js.map +1 -1
- package/lib/module/components/HeaderDynamic.js +34 -0
- package/lib/module/components/HeaderDynamic.js.map +1 -0
- package/lib/module/components/HeaderMotion.js +14 -20
- package/lib/module/components/HeaderMotion.js.map +1 -1
- package/lib/module/components/HeaderPanBoundary.js +54 -0
- package/lib/module/components/HeaderPanBoundary.js.map +1 -0
- package/lib/module/components/NavigationBridge.js +20 -0
- package/lib/module/components/NavigationBridge.js.map +1 -0
- package/lib/module/components/ScrollManager.js +19 -7
- package/lib/module/components/ScrollManager.js.map +1 -1
- package/lib/module/components/ScrollView.js +6 -39
- package/lib/module/components/ScrollView.js.map +1 -1
- package/lib/module/components/createHeaderMotionScrollable.js +136 -0
- package/lib/module/components/createHeaderMotionScrollable.js.map +1 -0
- package/lib/module/components/index.js +3 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/context.js +8 -1
- package/lib/module/context.js.map +1 -1
- package/lib/module/hooks/index.js +1 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/useActiveScrollId.js +7 -6
- package/lib/module/hooks/useActiveScrollId.js.map +1 -1
- package/lib/module/hooks/useConsumerScrollHandlers.js +86 -0
- package/lib/module/hooks/useConsumerScrollHandlers.js.map +1 -0
- package/lib/module/hooks/useHeaderMotionBridge.js +14 -0
- package/lib/module/hooks/useHeaderMotionBridge.js.map +1 -0
- package/lib/module/hooks/useMotionProgress.js +12 -42
- package/lib/module/hooks/useMotionProgress.js.map +1 -1
- package/lib/module/hooks/useMotionProgress.test.js +56 -0
- package/lib/module/hooks/useMotionProgress.test.js.map +1 -0
- package/lib/module/hooks/useScrollManager.js +168 -87
- package/lib/module/hooks/useScrollManager.js.map +1 -1
- package/lib/module/index.js +21 -18
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/defaults.js +2 -1
- package/lib/module/utils/defaults.js.map +1 -1
- package/lib/module/utils/header.js +24 -0
- package/lib/module/utils/header.js.map +1 -0
- package/lib/module/utils/headerOffsetStyle.js +31 -0
- package/lib/module/utils/headerOffsetStyle.js.map +1 -0
- package/lib/module/utils/index.js +2 -0
- package/lib/module/utils/index.js.map +1 -1
- package/lib/typescript/docs/docusaurus.config.d.ts +4 -0
- package/lib/typescript/docs/docusaurus.config.d.ts.map +1 -0
- package/lib/typescript/docs/sidebars.d.ts +4 -0
- package/lib/typescript/docs/sidebars.d.ts.map +1 -0
- package/lib/typescript/docs/src/pages/index.d.ts +2 -0
- package/lib/typescript/docs/src/pages/index.d.ts.map +1 -0
- package/lib/typescript/src/components/Bridge.d.ts +19 -0
- package/lib/typescript/src/components/Bridge.d.ts.map +1 -0
- package/lib/typescript/src/components/FlatList.d.ts +7 -15
- package/lib/typescript/src/components/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/Header.d.ts +73 -12
- package/lib/typescript/src/components/Header.d.ts.map +1 -1
- package/lib/typescript/src/components/HeaderDynamic.d.ts +11 -0
- package/lib/typescript/src/components/HeaderDynamic.d.ts.map +1 -0
- package/lib/typescript/src/components/HeaderMotion.d.ts +38 -23
- package/lib/typescript/src/components/HeaderMotion.d.ts.map +1 -1
- package/lib/typescript/src/components/HeaderPanBoundary.d.ts +11 -0
- package/lib/typescript/src/components/HeaderPanBoundary.d.ts.map +1 -0
- package/lib/typescript/src/components/NavigationBridge.d.ts +19 -0
- package/lib/typescript/src/components/NavigationBridge.d.ts.map +1 -0
- package/lib/typescript/src/components/ScrollManager.d.ts +13 -9
- package/lib/typescript/src/components/ScrollManager.d.ts.map +1 -1
- package/lib/typescript/src/components/ScrollView.d.ts +7 -14
- package/lib/typescript/src/components/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/createHeaderMotionScrollable.d.ts +86 -0
- package/lib/typescript/src/components/createHeaderMotionScrollable.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +3 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/context.d.ts +3 -17
- package/lib/typescript/src/context.d.ts.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/hooks/index.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useActiveScrollId.d.ts +7 -6
- package/lib/typescript/src/hooks/useActiveScrollId.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useConsumerScrollHandlers.d.ts +64 -0
- package/lib/typescript/src/hooks/useConsumerScrollHandlers.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useHeaderMotionBridge.d.ts +10 -0
- package/lib/typescript/src/hooks/useHeaderMotionBridge.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMotionProgress.d.ts +8 -25
- package/lib/typescript/src/hooks/useMotionProgress.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMotionProgress.test.d.ts +2 -0
- package/lib/typescript/src/hooks/useMotionProgress.test.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useScrollManager.d.ts +61 -29
- package/lib/typescript/src/hooks/useScrollManager.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +56 -26
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +54 -17
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/defaults.d.ts +3 -2
- package/lib/typescript/src/utils/defaults.d.ts.map +1 -1
- package/lib/typescript/src/utils/header.d.ts +10 -0
- package/lib/typescript/src/utils/header.d.ts.map +1 -0
- package/lib/typescript/src/utils/headerOffsetStyle.d.ts +19 -0
- package/lib/typescript/src/utils/headerOffsetStyle.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +2 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -1
- package/lib/typescript/src/utils/refreshControl.d.ts +12 -12
- package/package.json +12 -5
- package/src/components/Bridge.tsx +29 -0
- package/src/components/FlatList.tsx +18 -76
- package/src/components/Header.tsx +159 -23
- package/src/components/HeaderDynamic.tsx +45 -0
- package/src/components/HeaderMotion.tsx +47 -50
- package/src/components/HeaderPanBoundary.tsx +92 -0
- package/src/components/NavigationBridge.tsx +30 -0
- package/src/components/ScrollManager.tsx +23 -11
- package/src/components/ScrollView.tsx +16 -60
- package/src/components/createHeaderMotionScrollable.tsx +438 -0
- package/src/components/index.ts +3 -1
- package/src/context.ts +11 -24
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useActiveScrollId.ts +7 -6
- package/src/hooks/useConsumerScrollHandlers.ts +148 -0
- package/src/hooks/useHeaderMotionBridge.ts +15 -0
- package/src/hooks/useMotionProgress.test.ts +67 -0
- package/src/hooks/useMotionProgress.ts +12 -45
- package/src/hooks/useScrollManager.ts +251 -114
- package/src/index.ts +82 -36
- package/src/types.ts +81 -29
- package/src/utils/defaults.ts +7 -1
- package/src/utils/header.tsx +52 -0
- package/src/utils/headerOffsetStyle.ts +40 -0
- package/src/utils/index.ts +2 -0
- package/lib/module/components/HeaderBase.js +0 -107
- package/lib/module/components/HeaderBase.js.map +0 -1
- package/lib/typescript/src/components/HeaderBase.d.ts +0 -41
- package/lib/typescript/src/components/HeaderBase.d.ts.map +0 -1
- package/src/components/HeaderBase.tsx +0 -140
|
@@ -7,7 +7,7 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
7
7
|
onLayout?: ((event: import("react-native").LayoutChangeEvent) => unknown) | undefined;
|
|
8
8
|
onMagicTap?: (() => unknown) | undefined;
|
|
9
9
|
onAccessibilityEscape?: (() => unknown) | undefined;
|
|
10
|
-
}>, "
|
|
10
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onClick" | "onClickCapture" | "onMouseEnter" | "onMouseLeave" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onMoveShouldSetResponder" | "onMoveShouldSetResponderCapture" | "onResponderGrant" | "onResponderMove" | "onResponderReject" | "onResponderRelease" | "onResponderStart" | "onResponderEnd" | "onResponderTerminate" | "onResponderTerminationRequest" | "onStartShouldSetResponder" | "onStartShouldSetResponderCapture" | "onPointerEnterCapture" | "onPointerLeaveCapture" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
11
11
|
onMoveShouldSetResponder?: ((e: import("react-native").GestureResponderEvent) => boolean) | undefined;
|
|
12
12
|
onMoveShouldSetResponderCapture?: ((e: import("react-native").GestureResponderEvent) => boolean) | undefined;
|
|
13
13
|
onResponderGrant?: ((e: import("react-native").GestureResponderEvent) => void | boolean) | undefined;
|
|
@@ -20,10 +20,10 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
20
20
|
onResponderTerminationRequest?: ((e: import("react-native").GestureResponderEvent) => boolean) | undefined;
|
|
21
21
|
onStartShouldSetResponder?: ((e: import("react-native").GestureResponderEvent) => boolean) | undefined;
|
|
22
22
|
onStartShouldSetResponderCapture?: ((e: import("react-native").GestureResponderEvent) => boolean) | undefined;
|
|
23
|
-
}>, "
|
|
23
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onClick" | "onClickCapture" | "onMouseEnter" | "onMouseLeave" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onPointerEnterCapture" | "onPointerLeaveCapture" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
24
24
|
onMouseEnter?: ((event: import("react-native").MouseEvent) => void) | undefined;
|
|
25
25
|
onMouseLeave?: ((event: import("react-native").MouseEvent) => void) | undefined;
|
|
26
|
-
}>, "
|
|
26
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onClick" | "onClickCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onPointerEnterCapture" | "onPointerLeaveCapture" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
27
27
|
onClick?: ((event: import("react-native").PointerEvent) => void) | undefined;
|
|
28
28
|
onClickCapture?: ((event: import("react-native").PointerEvent) => void) | undefined;
|
|
29
29
|
onPointerEnter?: ((event: import("react-native").PointerEvent) => void) | undefined;
|
|
@@ -46,12 +46,12 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
46
46
|
onGotPointerCaptureCapture?: ((e: import("react-native").PointerEvent) => void) | undefined;
|
|
47
47
|
onLostPointerCapture?: ((e: import("react-native").PointerEvent) => void) | undefined;
|
|
48
48
|
onLostPointerCaptureCapture?: ((e: import("react-native").PointerEvent) => void) | undefined;
|
|
49
|
-
}>, "
|
|
49
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onClick" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
50
50
|
onBlur?: ((event: import("react-native").BlurEvent) => void) | undefined;
|
|
51
51
|
onBlurCapture?: ((event: import("react-native").BlurEvent) => void) | undefined;
|
|
52
52
|
onFocus?: ((event: import("react-native").FocusEvent) => void) | undefined;
|
|
53
53
|
onFocusCapture?: ((event: import("react-native").FocusEvent) => void) | undefined;
|
|
54
|
-
}>, "
|
|
54
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onClick" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
55
55
|
onTouchCancel?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
56
56
|
onTouchCancelCapture?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
57
57
|
onTouchEnd?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
@@ -60,7 +60,7 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
60
60
|
onTouchMoveCapture?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
61
61
|
onTouchStart?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
62
62
|
onTouchStartCapture?: ((e: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
63
|
-
}>, "
|
|
63
|
+
}>, "id" | "style" | "children" | "tabIndex" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "onClick" | "nativeBackgroundAndroid" | "nativeForegroundAndroid" | "renderToHardwareTextureAndroid" | "hasTVPreferredFocus" | "nextFocusDown" | "nextFocusForward" | "nextFocusLeft" | "nextFocusRight" | "nextFocusUp" | "focusable" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
64
64
|
nativeBackgroundAndroid?: import("react-native/types_generated/Libraries/Components/View/ViewPropTypes").AndroidDrawable | undefined;
|
|
65
65
|
nativeForegroundAndroid?: import("react-native/types_generated/Libraries/Components/View/ViewPropTypes").AndroidDrawable | undefined;
|
|
66
66
|
renderToHardwareTextureAndroid?: boolean | undefined;
|
|
@@ -73,16 +73,16 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
73
73
|
focusable?: boolean | undefined;
|
|
74
74
|
tabIndex?: 0 | -1;
|
|
75
75
|
onClick?: ((event: import("react-native").GestureResponderEvent) => unknown) | undefined;
|
|
76
|
-
}>, "
|
|
76
|
+
}>, "id" | "style" | "children" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "shouldRasterizeIOS" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
77
77
|
shouldRasterizeIOS?: boolean | undefined;
|
|
78
|
-
}>, "
|
|
78
|
+
}>, "id" | "style" | "children" | "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-labelledby" | "aria-live" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions" | "accessibilityLabelledBy" | "accessibilityLiveRegion" | "importantForAccessibility" | "screenReaderFocusable" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<Omit<Readonly<{
|
|
79
79
|
accessibilityLabelledBy?: (string | undefined) | (Array<string> | undefined);
|
|
80
80
|
"aria-labelledby"?: string | undefined;
|
|
81
81
|
accessibilityLiveRegion?: ("none" | "polite" | "assertive") | undefined;
|
|
82
82
|
"aria-live"?: ("polite" | "assertive" | "off") | undefined;
|
|
83
83
|
importantForAccessibility?: ("auto" | "yes" | "no" | "no-hide-descendants") | undefined;
|
|
84
84
|
screenReaderFocusable?: boolean;
|
|
85
|
-
}>, "
|
|
85
|
+
}>, "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-modal" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "accessibilityIgnoresInvertColors" | "accessibilityViewIsModal" | "accessibilityShowsLargeContentViewer" | "accessibilityLargeContentTitle" | "accessibilityElementsHidden" | "accessibilityLanguage" | "accessibilityRespondsToUserInteraction" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions"> & Omit<Readonly<{
|
|
86
86
|
accessibilityIgnoresInvertColors?: boolean | undefined;
|
|
87
87
|
accessibilityViewIsModal?: boolean | undefined;
|
|
88
88
|
accessibilityShowsLargeContentViewer?: boolean | undefined;
|
|
@@ -91,7 +91,7 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
91
91
|
accessibilityElementsHidden?: boolean | undefined;
|
|
92
92
|
accessibilityLanguage?: string | undefined;
|
|
93
93
|
accessibilityRespondsToUserInteraction?: boolean | undefined;
|
|
94
|
-
}>, "
|
|
94
|
+
}>, "role" | "aria-busy" | "aria-checked" | "aria-disabled" | "aria-expanded" | "aria-hidden" | "aria-label" | "aria-selected" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "accessible" | "accessibilityLabel" | "accessibilityHint" | "accessibilityRole" | "accessibilityState" | "accessibilityValue" | "accessibilityActions"> & {
|
|
95
95
|
accessible?: boolean | undefined;
|
|
96
96
|
accessibilityLabel?: string | undefined;
|
|
97
97
|
accessibilityHint?: string | undefined;
|
|
@@ -111,8 +111,8 @@ declare const AnimatedRefreshControl: import("react-native-reanimated/lib/typesc
|
|
|
111
111
|
"aria-expanded"?: boolean | undefined;
|
|
112
112
|
"aria-selected"?: boolean | undefined;
|
|
113
113
|
"aria-hidden"?: boolean | undefined;
|
|
114
|
-
}>, "
|
|
115
|
-
children?:
|
|
114
|
+
}>, "id" | "style" | "children" | "collapsable" | "collapsableChildren" | "testID" | "nativeID" | "needsOffscreenAlphaCompositing" | "hitSlop" | "pointerEvents" | "removeClippedSubviews" | "experimental_accessibilityOrder"> & Omit<Readonly<{
|
|
115
|
+
children?: import("react").ReactNode;
|
|
116
116
|
style?: import("react-native/types_generated/Libraries/StyleSheet/StyleSheet").ViewStyleProp | undefined;
|
|
117
117
|
collapsable?: boolean | undefined;
|
|
118
118
|
collapsableChildren?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-header-motion",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "Smooth, animated collapsible headers with scroll-based motion control in React Native",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"typecheck": "tsc",
|
|
39
39
|
"test": "jest",
|
|
40
40
|
"release": "release-it --only-version",
|
|
41
|
-
"lint": "eslint
|
|
41
|
+
"lint": "eslint src example docs/src docs/*.ts *.js"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"react-native",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"bugs": {
|
|
55
55
|
"url": "https://github.com/pawicao/react-native-header-motion/issues"
|
|
56
56
|
},
|
|
57
|
-
"homepage": "https://github.
|
|
57
|
+
"homepage": "https://pawicao.github.io/react-native-header-motion/",
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"registry": "https://registry.npmjs.org/"
|
|
60
60
|
},
|
|
@@ -89,11 +89,12 @@
|
|
|
89
89
|
"react": "*",
|
|
90
90
|
"react-native": "*",
|
|
91
91
|
"react-native-gesture-handler": "^2.0.0",
|
|
92
|
-
"react-native-reanimated": "
|
|
92
|
+
"react-native-reanimated": "^4.0.0",
|
|
93
93
|
"react-native-worklets": ">=0.4.0"
|
|
94
94
|
},
|
|
95
95
|
"workspaces": [
|
|
96
|
-
"example"
|
|
96
|
+
"example",
|
|
97
|
+
"docs"
|
|
97
98
|
],
|
|
98
99
|
"packageManager": "yarn@4.11.0",
|
|
99
100
|
"react-native-builder-bob": {
|
|
@@ -116,6 +117,12 @@
|
|
|
116
117
|
},
|
|
117
118
|
"jest": {
|
|
118
119
|
"preset": "react-native",
|
|
120
|
+
"setupFilesAfterEnv": [
|
|
121
|
+
"<rootDir>/jest-setup.js"
|
|
122
|
+
],
|
|
123
|
+
"transformIgnorePatterns": [
|
|
124
|
+
"node_modules/(?!(react-native|@react-native|react-native-reanimated|react-native-worklets)/)"
|
|
125
|
+
],
|
|
119
126
|
"modulePathIgnorePatterns": [
|
|
120
127
|
"<rootDir>/example/node_modules",
|
|
121
128
|
"<rootDir>/lib/"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useHeaderMotionBridge } from '../hooks/useHeaderMotionBridge';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { HeaderMotionBridgeValue } from '../types';
|
|
4
|
+
|
|
5
|
+
type HeaderRenderChildren = (value: HeaderMotionBridgeValue) => ReactNode;
|
|
6
|
+
|
|
7
|
+
export interface HeaderMotionBridgeProps {
|
|
8
|
+
/**
|
|
9
|
+
* Render function that receives the current HeaderMotion context value.
|
|
10
|
+
*
|
|
11
|
+
* Use this when you need to pass the library's context across a React tree
|
|
12
|
+
* boundary, most commonly into a navigation-rendered header.
|
|
13
|
+
*/
|
|
14
|
+
children: HeaderRenderChildren;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reads the current HeaderMotion context and exposes it through a render
|
|
19
|
+
* function so it can be forwarded into another subtree.
|
|
20
|
+
*/
|
|
21
|
+
export function Bridge({ children }: HeaderMotionBridgeProps) {
|
|
22
|
+
if (typeof children !== 'function') {
|
|
23
|
+
throw new Error(
|
|
24
|
+
'HeaderMotion.Bridge only accepts a render function as its child.'
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return children(useHeaderMotionBridge());
|
|
29
|
+
}
|
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import Animated, {
|
|
3
|
-
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
import Animated, {
|
|
3
|
+
type FlatListPropsWithLayout,
|
|
4
|
+
} from 'react-native-reanimated';
|
|
5
|
+
import {
|
|
6
|
+
createHeaderMotionScrollable,
|
|
7
|
+
type HeaderMotionScrollableOwnProps,
|
|
8
|
+
} from './createHeaderMotionScrollable';
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
export type HeaderMotionFlatListProps<T = any> = FlatListPropsWithLayout<T> &
|
|
11
|
+
HeaderMotionScrollableOwnProps<Animated.FlatList<T>>;
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Optional unique identifier for this scroll view.
|
|
12
|
-
* Use this when you have multiple scroll views (e.g. in tabs) to track them separately.
|
|
13
|
-
*/
|
|
14
|
-
scrollId?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Optional animated ref to use for the flat list.
|
|
17
|
-
* When provided, the scroll manager will use this ref instead of creating its own.
|
|
18
|
-
*/
|
|
19
|
-
animatedRef?: AnimatedRef<Animated.FlatList<T>> | AnimatedRef;
|
|
20
|
-
};
|
|
13
|
+
type FlatListComponent = <T = any>(
|
|
14
|
+
props: HeaderMotionFlatListProps<T>
|
|
15
|
+
) => ReactElement | null;
|
|
21
16
|
|
|
22
17
|
/**
|
|
23
18
|
* Animated FlatList component that integrates with HeaderMotion.
|
|
@@ -36,61 +31,8 @@ export type HeaderMotionFlatListProps<T = any> = ComponentProps<
|
|
|
36
31
|
* </HeaderMotion>
|
|
37
32
|
* ```
|
|
38
33
|
*/
|
|
39
|
-
export
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}: HeaderMotionFlatListProps<T>) {
|
|
45
|
-
return (
|
|
46
|
-
<HeaderMotionScrollManager
|
|
47
|
-
scrollId={scrollId}
|
|
48
|
-
animatedRef={animatedRef as AnimatedRef<Animated.FlatList<T>>}
|
|
49
|
-
refreshControl={props.refreshControl}
|
|
50
|
-
refreshing={props.refreshing}
|
|
51
|
-
onRefresh={props.onRefresh}
|
|
52
|
-
progressViewOffset={props.progressViewOffset}
|
|
53
|
-
>
|
|
54
|
-
{(
|
|
55
|
-
{
|
|
56
|
-
onScroll,
|
|
57
|
-
refreshControl: managedRefreshControl,
|
|
58
|
-
ref,
|
|
59
|
-
...scrollViewProps
|
|
60
|
-
},
|
|
61
|
-
{ originalHeaderHeight, minHeightContentContainerStyle }
|
|
62
|
-
) => (
|
|
63
|
-
<Animated.FlatList
|
|
64
|
-
{...scrollViewProps}
|
|
65
|
-
{...props}
|
|
66
|
-
ref={ref}
|
|
67
|
-
onScroll={onScroll}
|
|
68
|
-
{...(managedRefreshControl && {
|
|
69
|
-
refreshControl: managedRefreshControl,
|
|
70
|
-
})}
|
|
71
|
-
renderScrollComponent={(scrollComponentProps) => (
|
|
72
|
-
<AnimatedScrollContainer
|
|
73
|
-
{...scrollComponentProps}
|
|
74
|
-
contentContainerStyle={[
|
|
75
|
-
minHeightContentContainerStyle,
|
|
76
|
-
{ paddingTop: originalHeaderHeight },
|
|
77
|
-
contentContainerStyle,
|
|
78
|
-
]}
|
|
79
|
-
/>
|
|
80
|
-
)}
|
|
81
|
-
/>
|
|
82
|
-
)}
|
|
83
|
-
</HeaderMotionScrollManager>
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const AnimatedScrollContainer = forwardRef<
|
|
88
|
-
ComponentRef<typeof Animated.ScrollView>,
|
|
89
|
-
ScrollViewProps
|
|
90
|
-
>(({ children, contentContainerStyle, ...rest }, ref) => {
|
|
91
|
-
return (
|
|
92
|
-
<Animated.ScrollView {...rest} ref={ref}>
|
|
93
|
-
<Animated.View style={contentContainerStyle}>{children}</Animated.View>
|
|
94
|
-
</Animated.ScrollView>
|
|
95
|
-
);
|
|
96
|
-
});
|
|
34
|
+
export const FlatList = createHeaderMotionScrollable(Animated.FlatList, {
|
|
35
|
+
displayName: 'HeaderMotion.FlatList',
|
|
36
|
+
contentContainerMode: 'renderScrollComponent',
|
|
37
|
+
isComponentAnimated: true,
|
|
38
|
+
}) as FlatListComponent;
|
|
@@ -1,30 +1,166 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { StyleSheet, type ViewProps } from 'react-native';
|
|
2
|
+
import Animated from 'react-native-reanimated';
|
|
3
|
+
import { useHeaderMotionContextOrThrow } from '../context';
|
|
4
|
+
import type {
|
|
5
|
+
HeaderAsChildProps,
|
|
6
|
+
HeaderDefaultProps,
|
|
7
|
+
HeaderPanDecayConfig,
|
|
8
|
+
} from '../types';
|
|
9
|
+
import {
|
|
10
|
+
cloneWithOnLayout,
|
|
11
|
+
composeOnLayoutHandlers,
|
|
12
|
+
resolveSlottableChild,
|
|
13
|
+
} from '../utils';
|
|
14
|
+
import { HeaderDynamic } from './HeaderDynamic';
|
|
15
|
+
import { HeaderPanBoundary } from './HeaderPanBoundary';
|
|
4
16
|
|
|
5
|
-
type
|
|
17
|
+
type HeaderPanProps =
|
|
18
|
+
| {
|
|
19
|
+
/** Enables dragging the header itself to scroll the active scrollable.
|
|
20
|
+
*
|
|
21
|
+
* This is useful when the header covers a large portion of the screen
|
|
22
|
+
* and you want the gesture to feel continuous between header and content.
|
|
23
|
+
*
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
pannable: true;
|
|
27
|
+
/**
|
|
28
|
+
* Customizes the momentum animation that runs after a header pan ends.
|
|
29
|
+
*
|
|
30
|
+
* Use an object for a fixed decay profile. Use a function when the decay
|
|
31
|
+
* should depend on the end event, for example to dampen or amplify
|
|
32
|
+
* certain velocities.
|
|
33
|
+
*
|
|
34
|
+
* If you provide a function, it runs inside the gesture end worklet and
|
|
35
|
+
* **must itself be marked with the 'worklet' directive.**
|
|
36
|
+
*/
|
|
37
|
+
panDecayConfig?: HeaderPanDecayConfig;
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
pannable?: false | undefined;
|
|
41
|
+
panDecayConfig?: never;
|
|
42
|
+
};
|
|
6
43
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
44
|
+
export type HeaderProps =
|
|
45
|
+
| (HeaderDefaultProps &
|
|
46
|
+
HeaderPanProps & {
|
|
47
|
+
/**
|
|
48
|
+
* Applies the default absolute-positioned header layout.
|
|
49
|
+
*
|
|
50
|
+
* Leave this enabled for navigation headers and any header that should
|
|
51
|
+
* visually float above the scrollable content. Disable it only when you
|
|
52
|
+
* intentionally want the header to participate in normal layout flow.
|
|
53
|
+
*
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
56
|
+
overlay?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Wraps the pan gesture in `GestureHandlerRootView`.
|
|
59
|
+
*
|
|
60
|
+
* Only use this when the rendered header subtree is not already under a
|
|
61
|
+
* gesture-handler root.
|
|
62
|
+
*
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
withGestureHandlerRootView?: boolean;
|
|
66
|
+
})
|
|
67
|
+
| (HeaderAsChildProps &
|
|
68
|
+
HeaderPanProps & {
|
|
69
|
+
/**
|
|
70
|
+
* Wraps the pan gesture in `GestureHandlerRootView`.
|
|
71
|
+
*
|
|
72
|
+
* Only use this when the rendered header subtree is not already under a
|
|
73
|
+
* gesture-handler root.
|
|
74
|
+
*
|
|
75
|
+
* @default false
|
|
76
|
+
*/
|
|
77
|
+
withGestureHandlerRootView?: boolean;
|
|
78
|
+
});
|
|
14
79
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
80
|
+
const headerOverlayStyle = StyleSheet.create({
|
|
81
|
+
overlay: {
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
top: 0,
|
|
84
|
+
left: 0,
|
|
85
|
+
right: 0,
|
|
86
|
+
},
|
|
87
|
+
}).overlay;
|
|
88
|
+
|
|
89
|
+
function HeaderRoot(props: HeaderProps) {
|
|
90
|
+
const ctxValue = useHeaderMotionContextOrThrow(
|
|
91
|
+
'HeaderMotion.Header must be used within <HeaderMotion /> or <HeaderMotion.NavigationBridge />. If you are rendering inside a navigation header, bridge the context with <HeaderMotion.Bridge /> and <HeaderMotion.NavigationBridge />.'
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
if (props.asChild) {
|
|
95
|
+
const child = resolveSlottableChild('HeaderMotion.Header', props.children);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<HeaderPanBoundary
|
|
99
|
+
pannable={props.pannable}
|
|
100
|
+
panDecayConfig={props.panDecayConfig}
|
|
101
|
+
headerPanMomentumOffset={ctxValue.headerPanMomentumOffset}
|
|
102
|
+
scrollToRef={ctxValue.scrollToRef}
|
|
103
|
+
withGestureHandlerRootView={props.withGestureHandlerRootView}
|
|
104
|
+
>
|
|
105
|
+
{cloneWithOnLayout(
|
|
106
|
+
child,
|
|
107
|
+
ctxValue.measureTotalHeight,
|
|
108
|
+
'HeaderMotion.Header'
|
|
109
|
+
)}
|
|
110
|
+
</HeaderPanBoundary>
|
|
25
111
|
);
|
|
26
112
|
}
|
|
27
113
|
|
|
28
|
-
const
|
|
29
|
-
|
|
114
|
+
const {
|
|
115
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
116
|
+
asChild: _asChild,
|
|
117
|
+
overlay = true,
|
|
118
|
+
pannable,
|
|
119
|
+
panDecayConfig,
|
|
120
|
+
onLayout,
|
|
121
|
+
style,
|
|
122
|
+
withGestureHandlerRootView,
|
|
123
|
+
...rest
|
|
124
|
+
} = props;
|
|
125
|
+
const resolvedOnLayout = onLayout as ViewProps['onLayout'] | undefined;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<HeaderPanBoundary
|
|
129
|
+
pannable={pannable}
|
|
130
|
+
panDecayConfig={panDecayConfig}
|
|
131
|
+
headerPanMomentumOffset={ctxValue.headerPanMomentumOffset}
|
|
132
|
+
scrollToRef={ctxValue.scrollToRef}
|
|
133
|
+
withGestureHandlerRootView={withGestureHandlerRootView}
|
|
134
|
+
>
|
|
135
|
+
<Animated.View
|
|
136
|
+
{...rest}
|
|
137
|
+
onLayout={composeOnLayoutHandlers(
|
|
138
|
+
resolvedOnLayout,
|
|
139
|
+
ctxValue.measureTotalHeight
|
|
140
|
+
)}
|
|
141
|
+
style={[overlay ? headerOverlayStyle : undefined, style]}
|
|
142
|
+
/>
|
|
143
|
+
</HeaderPanBoundary>
|
|
144
|
+
);
|
|
30
145
|
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Header container that measures the total header height for scroll offsetting.
|
|
149
|
+
*
|
|
150
|
+
* It renders an `Animated.View` by default, wires the outer header measurement
|
|
151
|
+
* automatically, and can optionally make the header surface pannable.
|
|
152
|
+
*
|
|
153
|
+
* Pair it with `Header.Dynamic` to mark the part of the header that should
|
|
154
|
+
* drive the collapse threshold.
|
|
155
|
+
*/
|
|
156
|
+
export const Header = Object.assign(HeaderRoot, {
|
|
157
|
+
/**
|
|
158
|
+
* Marks the part of the header whose measured layout should define the
|
|
159
|
+
* collapsible distance.
|
|
160
|
+
*
|
|
161
|
+
* In most designs, this is the section that visually disappears while the
|
|
162
|
+
* header collapses. Its measured value feeds `measureDynamic`, which can in
|
|
163
|
+
* turn drive `progressThreshold`.
|
|
164
|
+
*/
|
|
165
|
+
Dynamic: HeaderDynamic,
|
|
166
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import Animated from 'react-native-reanimated';
|
|
3
|
+
import { useHeaderMotionContextOrThrow } from '../context';
|
|
4
|
+
import type { HeaderDynamicProps } from '../types';
|
|
5
|
+
import {
|
|
6
|
+
cloneWithOnLayout,
|
|
7
|
+
composeOnLayoutHandlers,
|
|
8
|
+
resolveSlottableChild,
|
|
9
|
+
} from '../utils';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Marks the part of the header whose layout should define the collapsible
|
|
13
|
+
* distance.
|
|
14
|
+
*
|
|
15
|
+
* In most designs, this is the section that visually disappears while the
|
|
16
|
+
* header collapses. Its measured value feeds `measureDynamic`, which in turn
|
|
17
|
+
* can drive `progressThreshold`.
|
|
18
|
+
*/
|
|
19
|
+
export function HeaderDynamic(props: HeaderDynamicProps) {
|
|
20
|
+
const ctxValue = useHeaderMotionContextOrThrow(
|
|
21
|
+
'HeaderMotion.Header.Dynamic must be used within <HeaderMotion /> or <HeaderMotion.NavigationBridge />. If you are rendering inside a navigation header, bridge the context with <HeaderMotion.Bridge /> and <HeaderMotion.NavigationBridge />.'
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (props.asChild) {
|
|
25
|
+
return cloneWithOnLayout(
|
|
26
|
+
resolveSlottableChild('HeaderMotion.Header.Dynamic', props.children),
|
|
27
|
+
ctxValue.measureDynamic,
|
|
28
|
+
'HeaderMotion.Header.Dynamic'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
const { asChild: _asChild, onLayout, ...rest } = props;
|
|
34
|
+
const resolvedOnLayout = onLayout as ViewProps['onLayout'] | undefined;
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Animated.View
|
|
38
|
+
{...rest}
|
|
39
|
+
onLayout={composeOnLayoutHandlers(
|
|
40
|
+
resolvedOnLayout,
|
|
41
|
+
ctxValue.measureDynamic
|
|
42
|
+
)}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|