react-native-header-motion 0.4.0 → 1.0.0-beta.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.
Files changed (140) hide show
  1. package/README.md +400 -335
  2. package/lib/module/components/Bridge.js +16 -0
  3. package/lib/module/components/Bridge.js.map +1 -0
  4. package/lib/module/components/FlatList.js +5 -62
  5. package/lib/module/components/FlatList.js.map +1 -1
  6. package/lib/module/components/Header.js +71 -13
  7. package/lib/module/components/Header.js.map +1 -1
  8. package/lib/module/components/HeaderDynamic.js +34 -0
  9. package/lib/module/components/HeaderDynamic.js.map +1 -0
  10. package/lib/module/components/HeaderMotion.js +59 -23
  11. package/lib/module/components/HeaderMotion.js.map +1 -1
  12. package/lib/module/components/HeaderPanBoundary.js +54 -0
  13. package/lib/module/components/HeaderPanBoundary.js.map +1 -0
  14. package/lib/module/components/NavigationBridge.js +20 -0
  15. package/lib/module/components/NavigationBridge.js.map +1 -0
  16. package/lib/module/components/ScrollManager.js +7 -5
  17. package/lib/module/components/ScrollManager.js.map +1 -1
  18. package/lib/module/components/ScrollView.js +6 -47
  19. package/lib/module/components/ScrollView.js.map +1 -1
  20. package/lib/module/components/createHeaderMotionScrollable.js +136 -0
  21. package/lib/module/components/createHeaderMotionScrollable.js.map +1 -0
  22. package/lib/module/components/index.js +3 -1
  23. package/lib/module/components/index.js.map +1 -1
  24. package/lib/module/context.js +8 -1
  25. package/lib/module/context.js.map +1 -1
  26. package/lib/module/hooks/index.js +1 -0
  27. package/lib/module/hooks/index.js.map +1 -1
  28. package/lib/module/hooks/useActiveScrollId.js +7 -6
  29. package/lib/module/hooks/useActiveScrollId.js.map +1 -1
  30. package/lib/module/hooks/useHeaderMotionBridge.js +14 -0
  31. package/lib/module/hooks/useHeaderMotionBridge.js.map +1 -0
  32. package/lib/module/hooks/useMotionProgress.js +10 -36
  33. package/lib/module/hooks/useMotionProgress.js.map +1 -1
  34. package/lib/module/hooks/useMotionProgress.test.js +56 -0
  35. package/lib/module/hooks/useMotionProgress.test.js.map +1 -0
  36. package/lib/module/hooks/useScrollManager.js +219 -109
  37. package/lib/module/hooks/useScrollManager.js.map +1 -1
  38. package/lib/module/index.js +21 -18
  39. package/lib/module/index.js.map +1 -1
  40. package/lib/module/utils/defaults.js +2 -1
  41. package/lib/module/utils/defaults.js.map +1 -1
  42. package/lib/module/utils/header.js +24 -0
  43. package/lib/module/utils/header.js.map +1 -0
  44. package/lib/module/utils/headerOffsetStyle.js +31 -0
  45. package/lib/module/utils/headerOffsetStyle.js.map +1 -0
  46. package/lib/module/utils/index.js +3 -0
  47. package/lib/module/utils/index.js.map +1 -1
  48. package/lib/module/utils/refreshControl.js +93 -0
  49. package/lib/module/utils/refreshControl.js.map +1 -0
  50. package/lib/module/utils/values.js +36 -0
  51. package/lib/module/utils/values.js.map +1 -1
  52. package/lib/typescript/src/components/Bridge.d.ts +19 -0
  53. package/lib/typescript/src/components/Bridge.d.ts.map +1 -0
  54. package/lib/typescript/src/components/FlatList.d.ts +7 -15
  55. package/lib/typescript/src/components/FlatList.d.ts.map +1 -1
  56. package/lib/typescript/src/components/Header.d.ts +73 -12
  57. package/lib/typescript/src/components/Header.d.ts.map +1 -1
  58. package/lib/typescript/src/components/HeaderDynamic.d.ts +11 -0
  59. package/lib/typescript/src/components/HeaderDynamic.d.ts.map +1 -0
  60. package/lib/typescript/src/components/HeaderMotion.d.ts +37 -18
  61. package/lib/typescript/src/components/HeaderMotion.d.ts.map +1 -1
  62. package/lib/typescript/src/components/HeaderPanBoundary.d.ts +11 -0
  63. package/lib/typescript/src/components/HeaderPanBoundary.d.ts.map +1 -0
  64. package/lib/typescript/src/components/NavigationBridge.d.ts +19 -0
  65. package/lib/typescript/src/components/NavigationBridge.d.ts.map +1 -0
  66. package/lib/typescript/src/components/ScrollManager.d.ts +18 -25
  67. package/lib/typescript/src/components/ScrollManager.d.ts.map +1 -1
  68. package/lib/typescript/src/components/ScrollView.d.ts +7 -14
  69. package/lib/typescript/src/components/ScrollView.d.ts.map +1 -1
  70. package/lib/typescript/src/components/createHeaderMotionScrollable.d.ts +86 -0
  71. package/lib/typescript/src/components/createHeaderMotionScrollable.d.ts.map +1 -0
  72. package/lib/typescript/src/components/index.d.ts +3 -1
  73. package/lib/typescript/src/components/index.d.ts.map +1 -1
  74. package/lib/typescript/src/context.d.ts +3 -13
  75. package/lib/typescript/src/context.d.ts.map +1 -1
  76. package/lib/typescript/src/hooks/index.d.ts +1 -0
  77. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  78. package/lib/typescript/src/hooks/useActiveScrollId.d.ts +7 -6
  79. package/lib/typescript/src/hooks/useActiveScrollId.d.ts.map +1 -1
  80. package/lib/typescript/src/hooks/useHeaderMotionBridge.d.ts +10 -0
  81. package/lib/typescript/src/hooks/useHeaderMotionBridge.d.ts.map +1 -0
  82. package/lib/typescript/src/hooks/useMotionProgress.d.ts +8 -25
  83. package/lib/typescript/src/hooks/useMotionProgress.d.ts.map +1 -1
  84. package/lib/typescript/src/hooks/useMotionProgress.test.d.ts +2 -0
  85. package/lib/typescript/src/hooks/useMotionProgress.test.d.ts.map +1 -0
  86. package/lib/typescript/src/hooks/useScrollManager.d.ts +63 -31
  87. package/lib/typescript/src/hooks/useScrollManager.d.ts.map +1 -1
  88. package/lib/typescript/src/index.d.ts +56 -26
  89. package/lib/typescript/src/index.d.ts.map +1 -1
  90. package/lib/typescript/src/types.d.ts +63 -15
  91. package/lib/typescript/src/types.d.ts.map +1 -1
  92. package/lib/typescript/src/utils/defaults.d.ts +3 -2
  93. package/lib/typescript/src/utils/defaults.d.ts.map +1 -1
  94. package/lib/typescript/src/utils/header.d.ts +10 -0
  95. package/lib/typescript/src/utils/header.d.ts.map +1 -0
  96. package/lib/typescript/src/utils/headerOffsetStyle.d.ts +19 -0
  97. package/lib/typescript/src/utils/headerOffsetStyle.d.ts.map +1 -0
  98. package/lib/typescript/src/utils/index.d.ts +3 -0
  99. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  100. package/lib/typescript/src/utils/refreshControl.d.ts +150 -0
  101. package/lib/typescript/src/utils/refreshControl.d.ts.map +1 -0
  102. package/lib/typescript/src/utils/values.d.ts +4 -1
  103. package/lib/typescript/src/utils/values.d.ts.map +1 -1
  104. package/package.json +13 -5
  105. package/src/components/Bridge.tsx +29 -0
  106. package/src/components/FlatList.tsx +18 -84
  107. package/src/components/Header.tsx +159 -23
  108. package/src/components/HeaderDynamic.tsx +45 -0
  109. package/src/components/HeaderMotion.tsx +114 -41
  110. package/src/components/HeaderPanBoundary.tsx +92 -0
  111. package/src/components/NavigationBridge.tsx +30 -0
  112. package/src/components/ScrollManager.tsx +38 -43
  113. package/src/components/ScrollView.tsx +16 -68
  114. package/src/components/createHeaderMotionScrollable.tsx +438 -0
  115. package/src/components/index.ts +3 -1
  116. package/src/context.ts +12 -18
  117. package/src/hooks/index.ts +1 -0
  118. package/src/hooks/useActiveScrollId.ts +7 -6
  119. package/src/hooks/useHeaderMotionBridge.ts +15 -0
  120. package/src/hooks/useMotionProgress.test.ts +67 -0
  121. package/src/hooks/useMotionProgress.ts +12 -37
  122. package/src/hooks/useScrollManager.ts +310 -129
  123. package/src/index.ts +82 -36
  124. package/src/types.ts +85 -25
  125. package/src/utils/defaults.ts +7 -1
  126. package/src/utils/header.tsx +52 -0
  127. package/src/utils/headerOffsetStyle.ts +40 -0
  128. package/src/utils/index.ts +3 -0
  129. package/src/utils/refreshControl.tsx +118 -0
  130. package/src/utils/values.ts +57 -1
  131. package/lib/module/components/HeaderBase.js +0 -59
  132. package/lib/module/components/HeaderBase.js.map +0 -1
  133. package/lib/module/hooks/refreshControl.js +0 -31
  134. package/lib/module/hooks/refreshControl.js.map +0 -1
  135. package/lib/typescript/src/components/HeaderBase.d.ts +0 -34
  136. package/lib/typescript/src/components/HeaderBase.d.ts.map +0 -1
  137. package/lib/typescript/src/hooks/refreshControl.d.ts +0 -13
  138. package/lib/typescript/src/hooks/refreshControl.d.ts.map +0 -1
  139. package/src/components/HeaderBase.tsx +0 -51
  140. package/src/hooks/refreshControl.ts +0 -55
@@ -0,0 +1,86 @@
1
+ import { type ReactElement, type Ref } from 'react';
2
+ import { type AnimatedProps, type AnimatedRef } from 'react-native-reanimated';
3
+ import type { InstanceOrElement } from 'react-native-reanimated/lib/typescript/commonTypes';
4
+ import type { HeaderMotionOffsetProps } from '../types';
5
+ export type HeaderMotionScrollableOwnProps<TRef extends InstanceOrElement = any> = HeaderMotionOffsetProps & {
6
+ /**
7
+ * Unique identifier for this scrollable when one header is shared across
8
+ * multiple scrollables.
9
+ */
10
+ scrollId?: string;
11
+ /**
12
+ * Animated ref to reuse instead of letting HeaderMotion create one.
13
+ */
14
+ animatedRef?: AnimatedRef<TRef> | AnimatedRef;
15
+ };
16
+ export interface CreateHeaderMotionScrollableOptions<TIsComponentAnimated extends boolean = boolean> {
17
+ displayName?: string;
18
+ /**
19
+ * If true, this function will NOT call Animated.createAnimatedComponent internally.
20
+ * Useful when you are creating a HeaderMotionScrollable from lists that already export their
21
+ * own (Re)animated components (e.g. LegendList).
22
+ *
23
+ * @default false
24
+ */
25
+ isComponentAnimated?: TIsComponentAnimated;
26
+ /**
27
+ * Controls how HeaderMotion injects content-container spacing.
28
+ *
29
+ * - `children`: wraps `children` in an inner `Animated.View`
30
+ * - `renderScrollComponent`: injects a custom scroll component that wraps the content
31
+ *
32
+ * Use `children` for ScrollView-like components. Use
33
+ * `renderScrollComponent` for FlatList-like components that own their
34
+ * internal scroll container.
35
+ *
36
+ * @default 'renderScrollComponent'
37
+ */
38
+ contentContainerMode?: ContentContainerMode;
39
+ }
40
+ export declare function createHeaderMotionScrollable<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean = false>(ScrollableComponent: TScrollableComponent, options?: CreateHeaderMotionScrollableOptions<TIsComponentAnimated>): HeaderMotionScrollableComponent<TScrollableComponent, TIsComponentAnimated>;
41
+ type ContentContainerMode = 'children' | 'renderScrollComponent';
42
+ type ScrollableComponent = ((props: any) => ReactElement | null) | (new (...args: any[]) => any);
43
+ declare const noListItemSymbol: unique symbol;
44
+ type NoListItem = {
45
+ readonly [noListItemSymbol]: true;
46
+ };
47
+ type ScrollableComponentProps<TScrollableComponent> = TScrollableComponent extends new (props: infer TProps, ...args: any[]) => any ? TProps : TScrollableComponent extends (props: infer TProps, ...args: any[]) => any ? TProps : never;
48
+ type IsUnknown<TValue> = unknown extends TValue ? [keyof TValue] extends [never] ? true : false : false;
49
+ type ReplaceUnknownDeep<TValue, TReplacement> = IsUnknown<TValue> extends true ? TReplacement : TValue extends (...args: infer TArgs) => infer TResult ? (...args: {
50
+ [TIndex in keyof TArgs]: ReplaceUnknownDeep<TArgs[TIndex], TReplacement>;
51
+ }) => TResult : TValue extends readonly (infer TItem)[] ? readonly ReplaceUnknownDeep<TItem, TReplacement>[] : TValue extends object ? {
52
+ [TKey in keyof TValue]: ReplaceUnknownDeep<TValue[TKey], TReplacement>;
53
+ } : TValue;
54
+ type MaybeAnimatedProps<TProps extends object, TIsComponentAnimated> = TIsComponentAnimated extends true ? TProps : AnimatedProps<TProps>;
55
+ type ResolveListItemProps<TProps extends object, TListItem> = [
56
+ TListItem
57
+ ] extends [NoListItem] ? TProps : ReplaceUnknownDeep<TProps, TListItem>;
58
+ type ExtractDataProp<TProps> = TProps extends {
59
+ data?: infer TData;
60
+ } ? TData : TProps extends {
61
+ data: infer TData;
62
+ } ? TData : never;
63
+ type ExtractListItemFromData<TData> = TData extends ReadonlyArray<infer TItem> | null | undefined ? TItem : TData extends ArrayLike<infer TItem> | null | undefined ? TItem : never;
64
+ type HasGenericDataProp<TProps> = IsUnknown<ExtractListItemFromData<ExtractDataProp<TProps>>>;
65
+ type ExtractRefTargetFromRef<TRef> = TRef extends Ref<infer TInstance> ? TInstance : TRef extends AnimatedRef<infer TInstance> ? TInstance : never;
66
+ type ExtractRefTargetFromProps<TProps> = TProps extends {
67
+ ref?: infer TRef;
68
+ } ? ExtractRefTargetFromRef<TRef> : TProps extends {
69
+ ref: infer TRef;
70
+ } ? ExtractRefTargetFromRef<TRef> : never;
71
+ type ResolveScrollableRefTarget<TScrollableComponent, TProps> = [
72
+ ExtractRefTargetFromProps<TProps>
73
+ ] extends [never] ? TScrollableComponent extends new (...args: any[]) => infer TInstance ? TInstance extends InstanceOrElement ? TInstance : any : any : ExtractRefTargetFromProps<TProps> extends InstanceOrElement ? ExtractRefTargetFromProps<TProps> : any;
74
+ type HeaderMotionScrollableBaseProps<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean, TListItem = NoListItem> = ResolveListItemProps<MaybeAnimatedProps<ScrollableComponentProps<TScrollableComponent>, TIsComponentAnimated>, TListItem>;
75
+ type HeaderMotionScrollablePublicProps<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean, TListItem = NoListItem> = HeaderMotionScrollableBaseProps<TScrollableComponent, TIsComponentAnimated, TListItem> & HeaderMotionScrollableOwnProps<ResolveScrollableRefTarget<TScrollableComponent, HeaderMotionScrollableBaseProps<TScrollableComponent, TIsComponentAnimated, TListItem>>>;
76
+ type HeaderMotionGenericScrollableComponent<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean> = {
77
+ <TListItem = any>(props: HeaderMotionScrollablePublicProps<TScrollableComponent, TIsComponentAnimated, TListItem>): ReactElement | null;
78
+ displayName?: string;
79
+ };
80
+ type HeaderMotionStaticScrollableComponent<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean> = {
81
+ (props: HeaderMotionScrollablePublicProps<TScrollableComponent, TIsComponentAnimated>): ReactElement | null;
82
+ displayName?: string;
83
+ };
84
+ type HeaderMotionScrollableComponent<TScrollableComponent extends ScrollableComponent, TIsComponentAnimated extends boolean> = HasGenericDataProp<ScrollableComponentProps<TScrollableComponent>> extends true ? HeaderMotionGenericScrollableComponent<TScrollableComponent, TIsComponentAnimated> : HeaderMotionStaticScrollableComponent<TScrollableComponent, TIsComponentAnimated>;
85
+ export {};
86
+ //# sourceMappingURL=createHeaderMotionScrollable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createHeaderMotionScrollable.d.ts","sourceRoot":"","sources":["../../../../src/components/createHeaderMotionScrollable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,YAAY,EAEjB,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AAEf,OAAiB,EACf,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oDAAoD,CAAC;AAE5F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,MAAM,MAAM,8BAA8B,CACxC,IAAI,SAAS,iBAAiB,GAAG,GAAG,IAClC,uBAAuB,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;CAC/C,CAAC;AAEF,MAAM,WAAW,mCAAmC,CAClD,oBAAoB,SAAS,OAAO,GAAG,OAAO;IAE9C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED,wBAAgB,4BAA4B,CAC1C,oBAAoB,SAAS,mBAAmB,EAChD,oBAAoB,SAAS,OAAO,GAAG,KAAK,EAE5C,mBAAmB,EAAE,oBAAoB,EACzC,OAAO,CAAC,EAAE,mCAAmC,CAAC,oBAAoB,CAAC,GAClE,+BAA+B,CAAC,oBAAoB,EAAE,oBAAoB,CAAC,CAgI7E;AAuDD,KAAK,oBAAoB,GAAG,UAAU,GAAG,uBAAuB,CAAC;AAEjE,KAAK,mBAAmB,GACpB,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,YAAY,GAAG,IAAI,CAAC,GACrC,C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AI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,KAAK,+BAA+B,CAClC,oBAAoB,SAAS,mBAAmB,EAChD,oBAAoB,SAAS,OAAO,IAClC,kBAAkB,CACpB,wBAAwB,CAAC,oBAAoB,CAAC,CAC/C,SAAS,IAAI,GACV,sCAAsC,CACpC,oBAAoB,EACpB,oBAAoB,CACrB,GACD,qCAAqC,CACnC,oBAAoB,EACpB,oBAAoB,CACrB,CAAC"}
@@ -1,7 +1,9 @@
1
+ export * from './Bridge';
1
2
  export * from './FlatList';
2
3
  export * from './Header';
3
- export * from './HeaderBase';
4
+ export * from './NavigationBridge';
4
5
  export * from './HeaderMotion';
5
6
  export * from './ScrollManager';
6
7
  export * from './ScrollView';
8
+ export * from './createHeaderMotionScrollable';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,gCAAgC,CAAC"}
@@ -1,14 +1,4 @@
1
- import { type SharedValue } from 'react-native-reanimated';
2
- import type { MeasureAnimatedHeaderAndSet, Progress, ScrollValues } from './types';
3
- interface HeaderMotionContextType {
4
- progress: Progress;
5
- measureTotalHeight: MeasureAnimatedHeaderAndSet;
6
- measureDynamic: MeasureAnimatedHeaderAndSet;
7
- scrollValues: SharedValue<ScrollValues>;
8
- activeScrollId: SharedValue<string> | undefined;
9
- progressThreshold: number;
10
- originalHeaderHeight: number;
11
- }
12
- export declare const HeaderMotionContext: import("react").Context<HeaderMotionContextType | null>;
13
- export {};
1
+ import type { HeaderMotionBridgeValue } from './types';
2
+ export declare const HeaderMotionContext: import("react").Context<HeaderMotionBridgeValue | null>;
3
+ export declare function useHeaderMotionContextOrThrow(errorMessage: string): HeaderMotionBridgeValue;
14
4
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EACV,2BAA2B,EAC3B,QAAQ,EACR,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,kBAAkB,EAAE,2BAA2B,CAAC;IAChD,cAAc,EAAE,2BAA2B,CAAC;IAC5C,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IACxC,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAChD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,oBAAoB,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,mBAAmB,yDACqB,CAAC"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAEvD,eAAO,MAAM,mBAAmB,yDACqB,CAAC;AAEtD,wBAAgB,6BAA6B,CAAC,YAAY,EAAE,MAAM,2BAOjE"}
@@ -1,4 +1,5 @@
1
1
  export * from './useActiveScrollId';
2
+ export * from './useHeaderMotionBridge';
2
3
  export * from './useMotionProgress';
3
4
  export * from './useScrollManager';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC"}
@@ -1,16 +1,17 @@
1
1
  import type { ActiveScrollIdValues, SetActiveScrollId } from '../types';
2
2
  /**
3
- * Hook to manage active scroll ID for multi-scroll scenarios (e.g. tabs with different scroll views).
4
- * Returns both a state value and a shared value, along with a setter function.
3
+ * Keeps a React state value and a shared value in sync for the currently active
4
+ * scrollable.
5
5
  *
6
- * Use this when you have multiple scroll views (like in a tabbed interface) and need to
7
- * track which one is currently active. Pass the shared value to `HeaderMotion`'s `activeScrollId` prop.
6
+ * Use this when one header is shared across multiple scroll views, for example
7
+ * pager pages or tabs. Pass `values.sv` to `HeaderMotion` and use the setter
8
+ * whenever the active page changes.
8
9
  *
9
10
  * @template T - The type of the scroll ID string
10
11
  * @param initialActiveScrollId - The initial active scroll ID
11
12
  * @returns A tuple containing:
12
- * - `[0]`: Object with `state` (React state) and `sv` (shared value) for the active scroll ID
13
- * - `[1]`: Function to set the active scroll ID
13
+ * - an object with both the React `state` and shared-value `sv`
14
+ * - a setter that updates both in lockstep
14
15
  *
15
16
  * @example
16
17
  * ```tsx
@@ -1 +1 @@
1
- {"version":3,"file":"useActiveScrollId.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActiveScrollId.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,qBAAqB,EAAE,CAAC,GACvB,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAuBjD"}
1
+ {"version":3,"file":"useActiveScrollId.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useActiveScrollId.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAChD,qBAAqB,EAAE,CAAC,GACvB,CAAC,oBAAoB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAuBjD"}
@@ -0,0 +1,10 @@
1
+ import type { HeaderMotionBridgeValue } from '../types';
2
+ /**
3
+ * Returns the full internal HeaderMotion context value.
4
+ *
5
+ * Most app code should use `useMotionProgress()` instead. Reach for this hook
6
+ * only when you need to carry HeaderMotion context across a tree boundary and
7
+ * re-provide it somewhere else.
8
+ */
9
+ export declare function useHeaderMotionBridge(): HeaderMotionBridgeValue;
10
+ //# sourceMappingURL=useHeaderMotionBridge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeaderMotionBridge.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useHeaderMotionBridge.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,uBAAuB,CAI/D"}
@@ -1,36 +1,19 @@
1
1
  import type { MotionProgress } from '../types';
2
2
  /**
3
- * Hook to access motion progress values and measuring functions for header animations.
4
- * Returns the progress value (0-1), threshold, and measurement functions.
3
+ * Returns the two shared values most header animations actually need:
4
+ * `progress` and `progressThreshold`.
5
5
  *
6
- * Must be used within a {@link HeaderMotion} component.
6
+ * Use this inside your animated header components to derive transforms,
7
+ * opacity, scale, parallax, or any other visual response to scroll.
7
8
  *
8
- * @returns Motion progress values and measuring functions:
9
- * - `progress`: Shared value from 0 to 1
10
- * - `progressThreshold`: The threshold at which animation completes
11
- * - `measureTotalHeight`: Function to measure total header height. Should be passed to the `onLayout` prop of the base of a header, to let scrollables account for the total header height
12
- * - `measureDynamic`: Function to measure a dimension of choice of the animated element of the header - should be passed to the `onLayout` prop of such. If used, can be used for dynamic calculation of the {@link progressThreshold}.
13
- *
14
- * @throws Error if used outside of a {@link HeaderMotion} component
9
+ * `progress` usually lives in the `0..1` range, where `0` is the expanded
10
+ * state and `1` is the fully collapsed state. `progressThreshold` is the pixel
11
+ * distance that corresponds to that transition.
15
12
  *
16
13
  * @example
17
14
  * ```tsx
18
15
  * function MyHeader() {
19
- * const { progress, progressThreshold, measureTotalHeight, measureDynamic } = useMotionProgress();
20
- * const dynamicStyle = useAnimatedStyle(() => {
21
- * const translateY = interpolate(
22
- * progress.value,
23
- * [0, 1],
24
- * [0, -progressThreshold],
25
- * Extrapolation.CLAMP,
26
- * )
27
- * return { transform: [{ translateY }] }
28
- * })
29
- * return (
30
- * <AnimatedHeaderBase onLayout={measureTotalHeight}>
31
- * <Animated.View onLayout={measureDynamic} style={dynamicStyle} />
32
- * </AnimatedHeaderBase>
33
- * )
16
+ * const { progress, progressThreshold } = useMotionProgress();
34
17
  * }
35
18
  * ```
36
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useMotionProgress.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useMotionProgress.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAgBlD"}
1
+ {"version":3,"file":"useMotionProgress.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useMotionProgress.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CASlD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=useMotionProgress.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMotionProgress.test.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useMotionProgress.test.ts"],"names":[],"mappings":""}
@@ -1,28 +1,67 @@
1
1
  import { type AnimatedRef } from 'react-native-reanimated';
2
2
  import type { ScrollManagerConfig } from '../types';
3
- import { type ResolveRefreshControlOptions } from './refreshControl';
3
+ import { type ResolveRefreshControlOptions } from '../utils';
4
+ import type { InstanceOrElement } from 'react-native-reanimated/lib/typescript/commonTypes';
4
5
  import { type ConsumerScrollEventHandlers } from './useConsumerScrollHandlers';
6
+ export interface UseScrollManagerOptions<TRef extends InstanceOrElement = any> extends Omit<ResolveRefreshControlOptions, 'progressViewOffset'>, ConsumerScrollEventHandlers {
7
+ /**
8
+ * Animated ref for the managed scrollable.
9
+ *
10
+ * Provide this when the caller also needs imperative access to the same
11
+ * scrollable instance. Otherwise the hook creates one internally.
12
+ */
13
+ animatedRef?: AnimatedRef<TRef>;
14
+ /**
15
+ * Overrides the refresh indicator offset.
16
+ *
17
+ * By default, HeaderMotion derives this from the measured header height so
18
+ * pull-to-refresh starts below the header. Override it only when you need a
19
+ * custom refresh placement.
20
+ */
21
+ progressViewOffset?: ResolveRefreshControlOptions['progressViewOffset'];
22
+ /**
23
+ * Ensures short content can still scroll far enough to fully collapse the
24
+ * header.
25
+ *
26
+ * **Experimental: this relies on extra layout measurement and may still be
27
+ * refined.**
28
+ *
29
+ * Enable this when your content is sometimes shorter than the viewport and
30
+ * you still want the header to reach the collapsed state.
31
+ */
32
+ ensureScrollableContentMinHeight?: boolean;
33
+ }
5
34
  /**
6
- * Hook that manages scroll tracking and synchronization for header animations.
7
- * Returns props to apply to scrollable components and additional values that help with adjusting styling of the scrollables to header's dimensions.
35
+ * Wires a custom scrollable into HeaderMotion.
8
36
  *
9
- * This hook handles:
10
- * - Scroll position tracking
11
- * - Synchronization between multiple scroll views (when using multiple scroll IDs)
12
- * - Content container minimum height calculations for cases where one of the tracked scrollables does not take enough space to reach the progress threshold/
37
+ * Most code should not use this hook directly.
13
38
  *
14
- * Must be used within a HeaderMotion component.
39
+ * **Prefer `createHeaderMotionScrollable()` whenever possible.** It gives
40
+ * you the same integration in a reusable component wrapper with less manual
41
+ * wiring. Reach for `useScrollManager()` only in more complex cases where the
42
+ * factory API is not enough, for example when a third-party scrollable needs
43
+ * highly custom composition.
15
44
  *
16
- * @param scrollId - Optional unique identifier for the related scrollable.
17
- * Use when you have multiple scrollables (e.g., in tabs).
18
- * @param options - Optional configuration object.
19
- * @param options.animatedRef - Optional animated ref to use instead of creating one internally.
20
- * Useful when you need access to the scroll view ref from outside.
21
- * @returns Configuration object containing:
22
- * - `scrollableProps`: Props to apply to scrollable component (onScroll, scrollEventThrottle, ref)
23
- * - `headerMotionContext`: Header context values (originalHeaderHeight, minHeightContentContainerStyle)
45
+ * It returns two things:
46
+ * - `scrollableProps`: the event handlers / ref / refresh-control props that
47
+ * should go on the scrollable itself
48
+ * - `headerMotionContext`: layout values you can use to offset the content
49
+ * below the measured header
24
50
  *
25
- * @throws Error if used outside of a HeaderMotion component
51
+ * In multi-scroll setups, pass a unique `scrollId` for each scrollable.
52
+ * In single-scroll setups, you usually do not need one.
53
+ *
54
+ * If you need the same fallback behavior but prefer render-prop composition
55
+ * over a hook, use `HeaderMotion.ScrollManager`.
56
+ *
57
+ * @param scrollId Optional unique identifier for the managed scrollable.
58
+ * @param options Optional configuration for refs, refresh handling, user
59
+ * scroll callbacks, and short-content fallback behavior.
60
+ * @returns Object containing:
61
+ * - `scrollableProps`: props to spread onto the scrollable (`ref`, managed
62
+ * `onScroll`, optional `onLayout`, and resolved `refreshControl`)
63
+ * - `headerMotionContext`: layout values for offsetting the content container
64
+ * (`originalHeaderHeight` and optional `contentContainerMinHeight`)
26
65
  *
27
66
  * @example
28
67
  * ```tsx
@@ -31,7 +70,12 @@ import { type ConsumerScrollEventHandlers } from './useConsumerScrollHandlers';
31
70
  *
32
71
  * return (
33
72
  * <CustomScrollView {...scrollableProps}>
34
- * <View style={{ paddingTop: headerMotionContext.originalHeaderHeight }}>
73
+ * <View
74
+ * style={{
75
+ * paddingTop: headerMotionContext.originalHeaderHeight,
76
+ * minHeight: headerMotionContext.contentContainerMinHeight,
77
+ * }}
78
+ * >
35
79
  * Content
36
80
  * </View>
37
81
  * </CustomScrollView>
@@ -39,17 +83,5 @@ import { type ConsumerScrollEventHandlers } from './useConsumerScrollHandlers';
39
83
  * }
40
84
  * ```
41
85
  */
42
- export interface UseScrollManagerOptions extends Omit<ResolveRefreshControlOptions, 'progressViewOffset'>, ConsumerScrollEventHandlers {
43
- /**
44
- * Optional animated ref to use instead of creating one internally.
45
- * Useful when you need access to the scroll view ref from outside.
46
- */
47
- animatedRef?: AnimatedRef<any>;
48
- /**
49
- * Optional refresh progress offset override.
50
- * When provided, it takes precedence over the automatic offset based on header height.
51
- */
52
- progressViewOffset?: ResolveRefreshControlOptions['progressViewOffset'];
53
- }
54
- export declare function useScrollManager(scrollId?: string, options?: UseScrollManagerOptions): ScrollManagerConfig;
86
+ export declare function useScrollManager<TRef extends InstanceOrElement = any>(scrollId?: string, options?: UseScrollManagerOptions<TRef>): ScrollManagerConfig<TRef>;
55
87
  //# sourceMappingURL=useScrollManager.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollManager.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useScrollManager.ts"],"names":[],"mappings":"AACA,OAAO,EAOL,KAAK,WAAW,EAEjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,mBAAmB,EAAgB,MAAM,UAAU,CAAC;AAElE,OA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,CAAC;CAC5C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,SAAS,iBAAiB,GAAG,GAAG,EACnE,QAAQ,CAAC,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,uBAAuB,CAAC,IAAI,CAAC,GACtC,mBAAmB,CAAC,IAAI,CAAC,CAuD3B"}
@@ -1,51 +1,81 @@
1
- import { AnimatedHeaderBase, HeaderBase, HeaderMotionFlatList, HeaderMotionHeader, HeaderMotionScrollManager, HeaderMotionScrollView, type HeaderMotionFlatListProps, type HeaderMotionHeaderProps, type HeaderMotionProps, type HeaderMotionScrollManagerProps, type HeaderMotionScrollViewProps } from './components';
2
- import type { ReactElement } from 'react';
3
- /**
4
- * Compound component type for HeaderMotion.
5
- * Provides the main context provider and sub-components for building collapsible headers.
6
- */
7
- type HeaderMotionComponent = {
8
- /** Main context provider component */
9
- <T extends string>(props: HeaderMotionProps<T>): ReactElement;
10
- /** Component for providing motion progress properties to animated headers.
11
- * Use to pass props to the header components in React Navigation / Expo Router, which cannot access HeaderMotion's context and `useMotionProgress` otherwise.
1
+ import { createHeaderMotionScrollable, Bridge, HeaderMotionContextProvider, FlatList, Header, NavigationBridge, ScrollManager, ScrollView, type CreateHeaderMotionScrollableOptions, type HeaderProps, type HeaderMotionBridgeProps, type HeaderMotionFlatListProps, type HeaderMotionNavigationBridgeProps, type HeaderMotionProps, type HeaderMotionScrollManagerProps, type HeaderMotionScrollableOwnProps, type HeaderMotionScrollViewProps } from './components';
2
+ import type { HeaderDynamicProps } from './types';
3
+ type HeaderMotionCompound = typeof HeaderMotionContextProvider & {
4
+ /**
5
+ * Header container that measures the total header height and can optionally
6
+ * make the header surface pannable.
7
+ *
8
+ * Use `HeaderMotion.Header.Dynamic` inside it to mark the part of the header
9
+ * that should define the collapse distance.
10
+ */
11
+ Header: typeof Header;
12
+ /**
13
+ * Captures the current HeaderMotion context and exposes it through a render
14
+ * function so it can be forwarded across a React tree boundary.
15
+ *
16
+ * This is primarily useful for navigation-rendered headers.
17
+ */
18
+ Bridge: typeof Bridge;
19
+ /**
20
+ * Re-provides a previously captured HeaderMotion context value in another
21
+ * subtree.
22
+ *
23
+ * This is primarily useful for navigation libraries that render headers
24
+ * outside the screen subtree where `HeaderMotion` lives.
12
25
  */
13
- Header: typeof HeaderMotionHeader;
14
- /** Component for custom scroll implementations */
15
- ScrollManager: typeof HeaderMotionScrollManager;
16
- /** Animated ScrollView component with header motion integration */
17
- ScrollView: typeof HeaderMotionScrollView;
18
- /** Animated FlatList component with header motion integration */
19
- FlatList: typeof HeaderMotionFlatList;
26
+ NavigationBridge: typeof NavigationBridge;
27
+ /**
28
+ * Render-prop wrapper for managing a custom scrollable.
29
+ *
30
+ * Prefer `createHeaderMotionScrollable()` for most custom integrations. Use
31
+ * `ScrollManager` only when the factory approach is not flexible enough.
32
+ */
33
+ ScrollManager: typeof ScrollManager;
34
+ /**
35
+ * Pre-wired `Animated.ScrollView` that participates in HeaderMotion's scroll
36
+ * tracking and header offsetting.
37
+ */
38
+ ScrollView: typeof ScrollView;
39
+ /**
40
+ * Pre-wired `Animated.FlatList` that participates in HeaderMotion's scroll
41
+ * tracking and header offsetting.
42
+ */
43
+ FlatList: typeof FlatList;
20
44
  };
21
45
  /**
22
46
  * Main HeaderMotion component.
23
- * A compound component that provides context for collapsible header animations.
47
+ * Root provider and compound entrypoint for the library.
48
+ *
49
+ * It tracks header measurements, derives the shared `progress` value, and
50
+ * exposes the pre-wired subcomponents used to connect headers and scrollables.
24
51
  *
25
52
  * @example
26
53
  * ```tsx
27
54
  * <HeaderMotion>
28
- * <HeaderMotion.Header>
29
- * {(headerProps) => (
55
+ * <HeaderMotion.Bridge>
56
+ * {(value) => (
30
57
  * <Stack.Screen
31
58
  * options={{
32
59
  * header: () => (
33
- * <MyAnimatedHeader {...headerProps} />
60
+ * <HeaderMotion.NavigationBridge value={value}>
61
+ * <MyAnimatedHeader />
62
+ * </HeaderMotion.NavigationBridge>
34
63
  * ),
35
64
  * }}
36
65
  * />
37
66
  * )}
38
- * </HeaderMotion.Header>
67
+ * </HeaderMotion.Bridge>
39
68
  * <HeaderMotion.ScrollView>
40
69
  * <MyScrollableContent />
41
70
  * </HeaderMotion.ScrollView>
42
71
  * </HeaderMotion>
43
72
  * ```
44
73
  */
45
- declare const HeaderMotion: HeaderMotionComponent;
74
+ declare const HeaderMotion: HeaderMotionCompound;
46
75
  export default HeaderMotion;
47
76
  export * from './hooks';
48
77
  export type * from './types';
49
- export { AnimatedHeaderBase, HeaderBase };
50
- export type { HeaderMotionFlatListProps, HeaderMotionHeaderProps, HeaderMotionProps, HeaderMotionScrollManagerProps, HeaderMotionScrollViewProps, };
78
+ export { createHeaderMotionScrollable };
79
+ export { Bridge, Header, NavigationBridge };
80
+ export type { CreateHeaderMotionScrollableOptions, HeaderDynamicProps, HeaderMotionFlatListProps, HeaderMotionBridgeProps, HeaderMotionNavigationBridgeProps, HeaderMotionProps, HeaderMotionScrollManagerProps, HeaderMotionScrollableOwnProps, HeaderMotionScrollViewProps, HeaderProps, };
51
81
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,UAAU,EAEV,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,sBAAsB,EACtB,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,8BAA8B,EACnC,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C;;;GAGG;AACH,KAAK,qBAAqB,GAAG;IAC3B,sCAAsC;IACtC,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,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a,EAAE,OAAO,aAAa,CAAC;IACpC;;;OAGG;IACH,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B;;;OAGG;IACH,QAAQ,EAAE,OAAO,QAAQ,CAAC;CAC3B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,QAAA,MAAM,YAAY,EAAE,oBAUnB,CAAC;AAEF,eAAe,YAAY,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,mBAAmB,SAAS,CAAC;AAC7B,OAAO,EAAE,4BAA4B,EAAE,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;AAC5C,YAAY,EACV,mCAAmC,EACnC,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,iCAAiC,EACjC,iBAAiB,EACjB,8BAA8B,EAC9B,8BAA8B,EAC9B,2BAA2B,EAC3B,WAAW,GACZ,CAAC"}
@@ -1,8 +1,40 @@
1
1
  import type { ReactElement } from 'react';
2
- import type { LayoutChangeEvent, RefreshControlProps, ScrollViewProps } from 'react-native';
3
- import type { AnimatedRef, SharedValue } from 'react-native-reanimated';
2
+ import type { LayoutChangeEvent, ScrollViewProps, ViewProps } from 'react-native';
3
+ import type { AnimatedProps, AnimatedRef, SharedValue } from 'react-native-reanimated';
4
4
  import { DEFAULT_SCROLL_ID } from './utils/defaults';
5
+ import type { InstanceOrElement } from 'react-native-reanimated/lib/typescript/commonTypes';
6
+ import type { GestureStateChangeEvent, PanGestureHandlerEventPayload } from 'react-native-gesture-handler';
7
+ import type { WithDecayConfig } from 'react-native-reanimated';
5
8
  export type Progress = SharedValue<number>;
9
+ export type HeaderMotionOffsetStrategy = 'padding' | 'margin' | 'top' | 'translate' | 'none';
10
+ export interface HeaderMotionOffsetProps {
11
+ /**
12
+ * How the scrollable content should be pushed below the measured header.
13
+ *
14
+ * `padding` is the safest default for most screens. `margin`, `top`, and
15
+ * `translate` can be useful when the scrollable or its children need a
16
+ * different layout behavior.
17
+ *
18
+ * `top` and `translate` add bottom compensation so the end of the content
19
+ * remains reachable.
20
+ *
21
+ * @default 'padding'
22
+ */
23
+ headerOffsetStrategy?: HeaderMotionOffsetStrategy;
24
+ /**
25
+ * Adds a minimum content height so scrollables with short content can still collapse the
26
+ * header completely.
27
+ *
28
+ * **Experimental: this relies on extra layout measurement and may still be
29
+ * refined.**
30
+ *
31
+ * Enable this when some screens do not have enough content to naturally
32
+ * scroll through the full collapse distance.
33
+ *
34
+ * @default false
35
+ */
36
+ ensureScrollableContentMinHeight?: boolean;
37
+ }
6
38
  export type ProgressThreshold = number | ((measuredHeaderValue: number) => number);
7
39
  export type MeasureAnimatedHeader = (e: LayoutChangeEvent) => number;
8
40
  export type MeasureAnimatedHeaderAndSet = (e: LayoutChangeEvent) => void;
@@ -18,31 +50,47 @@ export interface ScrollValue {
18
50
  export type ScrollValues = Record<string, ScrollValue> & {
19
51
  [key in typeof DEFAULT_SCROLL_ID]?: ScrollValue;
20
52
  };
21
- export type WithCollapsibleHeaderProps<T extends Record<string, unknown> = Record<string, unknown>> = T & MotionProgress;
22
- export type WithCollapsiblePagedHeaderProps<Tab extends string = string, T extends Record<string, unknown> = Record<string, unknown>> = WithCollapsibleHeaderProps<T> & {
23
- onTabChange: (newTab: Tab) => void;
24
- activeTab: Tab;
25
- };
26
53
  export interface MotionProgress {
27
54
  progress: Progress;
28
- progressThreshold: number;
55
+ progressThreshold: SharedValue<number>;
56
+ }
57
+ export type HeaderPanDecayEvent = GestureStateChangeEvent<PanGestureHandlerEventPayload>;
58
+ export type HeaderPanDecayConfig = WithDecayConfig | ((event: HeaderPanDecayEvent) => WithDecayConfig);
59
+ export type HeaderAsChildProps = {
60
+ asChild: true;
61
+ children: ReactElement;
62
+ };
63
+ export type HeaderDefaultProps = AnimatedProps<ViewProps> & {
64
+ asChild?: false;
65
+ };
66
+ export type HeaderDynamicProps = HeaderDefaultProps | HeaderAsChildProps;
67
+ export interface HeaderMotionBridgeValue extends MotionProgress {
29
68
  measureTotalHeight: MeasureAnimatedHeaderAndSet;
30
69
  measureDynamic: MeasureAnimatedHeaderAndSet;
70
+ headerPanMomentumOffset: SharedValue<number | null>;
71
+ scrollValues: SharedValue<ScrollValues>;
72
+ activeScrollId: SharedValue<string> | undefined;
73
+ scrollToRef: React.RefObject<ScrollTo | null>;
74
+ originalHeaderHeight: number;
31
75
  }
32
76
  export interface ScrollManagerHeaderMotionContext {
33
77
  originalHeaderHeight: number;
34
- minHeightContentContainerStyle: {} | {
35
- minHeight: number;
36
- };
78
+ contentContainerMinHeight?: number;
37
79
  }
38
- export interface ScrollManagerConfig {
39
- scrollableProps: Required<Pick<ScrollViewProps, 'onScroll' | 'scrollEventThrottle'>> & {
40
- refreshControl?: ReactElement<RefreshControlProps>;
41
- ref: AnimatedRef<any>;
80
+ export interface ScrollManagerConfig<TRef extends InstanceOrElement = any> {
81
+ scrollableProps: Pick<ScrollViewProps, 'onScroll' | 'onLayout'> & {
82
+ refreshControl?: ReactElement;
83
+ ref: AnimatedRef<TRef>;
42
84
  };
43
85
  headerMotionContext: ScrollManagerHeaderMotionContext;
44
86
  }
87
+ export type ScrollTo = (y: number, options?: ScrollToOptions) => void;
45
88
  export type ScrollHandlerContext = {
46
89
  lastOffset: number | undefined;
47
90
  };
91
+ interface ScrollToOptions {
92
+ isValueDelta?: boolean;
93
+ animated?: boolean;
94
+ }
95
+ export {};
48
96
  //# sourceMappingURL=types.d.ts.map