@impulse-ui-native/scroll-view 0.0.0-stage → 9.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ImpulseUI Native contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,60 @@
1
- # Temporary Holding Version
1
+ # @impulse-ui-native/scroll-view
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Native React Native ScrollView and a small hook to reveal an initially selected child with its actual measured size.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ pnpm add @impulse-ui-native/scroll-view
9
+ ```
10
+
11
+ React and React Native are peer dependencies. No theme provider is required. The toolkit also exports this package.
12
+
13
+ ## Usage
14
+
15
+ ```tsx
16
+ import { useRef } from "react";
17
+ import { Pressable, Text } from "react-native";
18
+
19
+ import {
20
+ ScrollView,
21
+ useScrollViewInitialScroll,
22
+ } from "@impulse-ui-native/scroll-view";
23
+
24
+ function Options({ items, selectedValue }) {
25
+ const initialValue = useRef(selectedValue).current;
26
+ const scroll = useScrollViewInitialScroll({ horizontal: true });
27
+
28
+ return (
29
+ <ScrollView
30
+ ref={scroll.scrollViewRef}
31
+ horizontal
32
+ onLayout={scroll.onLayout}
33
+ onContentSizeChange={scroll.onContentSizeChange}
34
+ onScrollBeginDrag={scroll.onScrollBeginDrag}
35
+ >
36
+ {items.map((item) => (
37
+ <Pressable
38
+ key={item.value}
39
+ ref={item.value === initialValue ? scroll.targetRef : undefined}
40
+ onLayout={
41
+ item.value === initialValue ? scroll.onTargetLayout : undefined
42
+ }
43
+ >
44
+ <Text>{item.label}</Text>
45
+ </Pressable>
46
+ ))}
47
+ </ScrollView>
48
+ );
49
+ }
50
+ ```
51
+
52
+ The hook waits for viewport, content, and target layout, then measures the target relative to the native ScrollView with `measureLayout`. This uses layout coordinates rather than the current visual scroll position. Nested native wrappers, padding, gaps, and variable item sizes are included. Attach `targetRef` to one native View or a component forwarding its native View ref. Compose `onTargetLayout` with any existing item layout callback.
53
+
54
+ It scrolls only far enough to reveal the target, without animation. Already visible items retain the initial position; oversized items align at their leading edge. The default axis is vertical; pass `horizontal: true` to the hook and ScrollView for horizontal content.
55
+
56
+ Pass `enabled: false` to skip positioning. Pass native `contentOffset` to both the hook and ScrollView to preserve an explicit starting position. Existing `onLayout`, `onContentSizeChange`, and `onScrollBeginDrag` callbacks can be passed to the hook; its returned handlers invoke them with the original arguments. Other native props remain available because `ScrollView` is the native component.
57
+
58
+ Positioning happens once per mount. A user drag cancels pending positioning. Later selection and layout changes do not scroll again. Mount with the initial selection and content available, and remount when a fresh initial position is needed. This hook is for ordinary, unzoomed ScrollViews without automatic/custom content insets or snapping.
59
+
60
+ Exports: `ScrollView`, `ScrollViewProps`, `useScrollViewInitialScroll`, and `UseScrollViewInitialScrollOptions`.
@@ -0,0 +1,4 @@
1
+ export { useScrollViewInitialScroll } from './use-scroll-view-initial-scroll.hook.mjs';
2
+ import 'react-native';
3
+ import 'react';
4
+ import '../types/use-scroll-view-initial-scroll.types.mjs';
@@ -0,0 +1,2 @@
1
+ export * from "./use-scroll-view-initial-scroll.hook";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/index.ts"],"sourcesContent":["export * from \"./use-scroll-view-initial-scroll.hook\";\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,14 @@
1
+ import { ScrollView, View, LayoutChangeEvent, NativeSyntheticEvent, NativeScrollEvent } from 'react-native';
2
+ import * as react from 'react';
3
+ import { UseScrollViewInitialScrollOptions } from '../types/use-scroll-view-initial-scroll.types.mjs';
4
+
5
+ declare function useScrollViewInitialScroll({ enabled, horizontal, contentOffset, onLayout, onContentSizeChange, onScrollBeginDrag, }?: UseScrollViewInitialScrollOptions): {
6
+ scrollViewRef: react.RefObject<ScrollView | null>;
7
+ targetRef: react.RefObject<View | null>;
8
+ onTargetLayout: () => void;
9
+ onLayout: (event: LayoutChangeEvent) => void;
10
+ onContentSizeChange: (width: number, height: number) => void;
11
+ onScrollBeginDrag: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
12
+ };
13
+
14
+ export { useScrollViewInitialScroll };
@@ -0,0 +1,104 @@
1
+ import { useRef } from "react";
2
+ import { useEventCallback } from "@impulse-ui-native/core";
3
+ import { getScrollViewRevealOffset } from "../utils/get-scroll-view-reveal-offset";
4
+ function useScrollViewInitialScroll({
5
+ enabled = true,
6
+ horizontal = false,
7
+ contentOffset,
8
+ onLayout,
9
+ onContentSizeChange,
10
+ onScrollBeginDrag
11
+ } = {}) {
12
+ const scrollViewRef = useRef(null);
13
+ const targetRef = useRef(null);
14
+ const viewportSizeRef = useRef(0);
15
+ const contentSizeRef = useRef(0);
16
+ const completedRef = useRef(false);
17
+ const measuringRef = useRef(false);
18
+ const handleMeasurement = useEventCallback(
19
+ ({ scrollView, target, layout }) => {
20
+ measuringRef.current = false;
21
+ if (!enabled || contentOffset || completedRef.current) {
22
+ return;
23
+ }
24
+ if (scrollViewRef.current !== scrollView || targetRef.current !== target) {
25
+ return;
26
+ }
27
+ const targetSize = horizontal ? layout.width : layout.height;
28
+ if (targetSize <= 0) {
29
+ return;
30
+ }
31
+ const offset = getScrollViewRevealOffset({
32
+ layout,
33
+ viewportSize: viewportSizeRef.current,
34
+ contentSize: contentSizeRef.current,
35
+ horizontal: Boolean(horizontal)
36
+ });
37
+ completedRef.current = true;
38
+ if (offset !== null) {
39
+ scrollView.scrollTo(
40
+ horizontal ? { x: offset, animated: false } : { y: offset, animated: false }
41
+ );
42
+ }
43
+ }
44
+ );
45
+ const handleMeasurementFailure = useEventCallback(() => {
46
+ measuringRef.current = false;
47
+ });
48
+ const revealTarget = useEventCallback(() => {
49
+ const scrollView = scrollViewRef.current;
50
+ const target = targetRef.current;
51
+ if (!enabled || contentOffset || completedRef.current || measuringRef.current) {
52
+ return;
53
+ }
54
+ if (!scrollView || !target || viewportSizeRef.current <= 0 || contentSizeRef.current <= 0) {
55
+ return;
56
+ }
57
+ const nativeScrollView = scrollView.getNativeScrollRef();
58
+ if (nativeScrollView == null) {
59
+ return;
60
+ }
61
+ measuringRef.current = true;
62
+ target.measureLayout(
63
+ nativeScrollView,
64
+ (x, y, width, height) => {
65
+ handleMeasurement({
66
+ scrollView,
67
+ target,
68
+ layout: { x, y, width, height }
69
+ });
70
+ },
71
+ handleMeasurementFailure
72
+ );
73
+ });
74
+ const handleLayout = useEventCallback((event) => {
75
+ viewportSizeRef.current = horizontal ? event.nativeEvent.layout.width : event.nativeEvent.layout.height;
76
+ revealTarget();
77
+ onLayout?.(event);
78
+ });
79
+ const handleContentSizeChange = useEventCallback(
80
+ (width, height) => {
81
+ contentSizeRef.current = horizontal ? width : height;
82
+ revealTarget();
83
+ onContentSizeChange?.(width, height);
84
+ }
85
+ );
86
+ const handleScrollBeginDrag = useEventCallback(
87
+ (event) => {
88
+ completedRef.current = true;
89
+ onScrollBeginDrag?.(event);
90
+ }
91
+ );
92
+ return {
93
+ scrollViewRef,
94
+ targetRef,
95
+ onTargetLayout: revealTarget,
96
+ onLayout: handleLayout,
97
+ onContentSizeChange: handleContentSizeChange,
98
+ onScrollBeginDrag: handleScrollBeginDrag
99
+ };
100
+ }
101
+ export {
102
+ useScrollViewInitialScroll
103
+ };
104
+ //# sourceMappingURL=use-scroll-view-initial-scroll.hook.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/hooks/use-scroll-view-initial-scroll.hook.ts"],"sourcesContent":["import type {\n LayoutChangeEvent,\n NativeScrollEvent,\n NativeSyntheticEvent,\n ScrollView,\n View,\n} from \"react-native\";\nimport { useRef } from \"react\";\n\nimport { useEventCallback } from \"@impulse-ui-native/core\";\n\nimport type { UseScrollViewInitialScrollOptions } from \"../types\";\nimport type { ScrollViewMeasurement } from \"../types/scroll-view-measurement.types\";\nimport { getScrollViewRevealOffset } from \"../utils/get-scroll-view-reveal-offset\";\n\nexport function useScrollViewInitialScroll({\n enabled = true,\n horizontal = false,\n contentOffset,\n onLayout,\n onContentSizeChange,\n onScrollBeginDrag,\n}: UseScrollViewInitialScrollOptions = {}) {\n const scrollViewRef = useRef<ScrollView>(null);\n const targetRef = useRef<View>(null);\n const viewportSizeRef = useRef(0);\n const contentSizeRef = useRef(0);\n const completedRef = useRef(false);\n const measuringRef = useRef(false);\n\n const handleMeasurement = useEventCallback(\n ({ scrollView, target, layout }: ScrollViewMeasurement) => {\n measuringRef.current = false;\n\n if (!enabled || contentOffset || completedRef.current) {\n return;\n }\n\n if (\n scrollViewRef.current !== scrollView ||\n targetRef.current !== target\n ) {\n return;\n }\n\n const targetSize = horizontal ? layout.width : layout.height;\n\n if (targetSize <= 0) {\n return;\n }\n\n const offset = getScrollViewRevealOffset({\n layout,\n viewportSize: viewportSizeRef.current,\n contentSize: contentSizeRef.current,\n horizontal: Boolean(horizontal),\n });\n\n completedRef.current = true;\n\n if (offset !== null) {\n scrollView.scrollTo(\n horizontal\n ? { x: offset, animated: false }\n : { y: offset, animated: false },\n );\n }\n },\n );\n\n const handleMeasurementFailure = useEventCallback(() => {\n measuringRef.current = false;\n });\n\n const revealTarget = useEventCallback(() => {\n const scrollView = scrollViewRef.current;\n const target = targetRef.current;\n\n if (\n !enabled ||\n contentOffset ||\n completedRef.current ||\n measuringRef.current\n ) {\n return;\n }\n\n if (\n !scrollView ||\n !target ||\n viewportSizeRef.current <= 0 ||\n contentSizeRef.current <= 0\n ) {\n return;\n }\n\n const nativeScrollView = scrollView.getNativeScrollRef();\n\n if (nativeScrollView == null) {\n return;\n }\n\n measuringRef.current = true;\n target.measureLayout(\n nativeScrollView,\n (x, y, width, height) => {\n handleMeasurement({\n scrollView,\n target,\n layout: { x, y, width, height },\n });\n },\n handleMeasurementFailure,\n );\n });\n\n const handleLayout = useEventCallback((event: LayoutChangeEvent) => {\n viewportSizeRef.current = horizontal\n ? event.nativeEvent.layout.width\n : event.nativeEvent.layout.height;\n\n revealTarget();\n onLayout?.(event);\n });\n\n const handleContentSizeChange = useEventCallback(\n (width: number, height: number) => {\n contentSizeRef.current = horizontal ? width : height;\n\n revealTarget();\n onContentSizeChange?.(width, height);\n },\n );\n\n const handleScrollBeginDrag = useEventCallback(\n (event: NativeSyntheticEvent<NativeScrollEvent>) => {\n completedRef.current = true;\n\n onScrollBeginDrag?.(event);\n },\n );\n\n return {\n scrollViewRef,\n targetRef,\n onTargetLayout: revealTarget,\n onLayout: handleLayout,\n onContentSizeChange: handleContentSizeChange,\n onScrollBeginDrag: handleScrollBeginDrag,\n };\n}\n"],"mappings":"AAOA,SAAS,cAAc;AAEvB,SAAS,wBAAwB;AAIjC,SAAS,iCAAiC;AAEnC,SAAS,2BAA2B;AAAA,EACzC,UAAU;AAAA,EACV,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAuC,CAAC,GAAG;AACzC,QAAM,gBAAgB,OAAmB,IAAI;AAC7C,QAAM,YAAY,OAAa,IAAI;AACnC,QAAM,kBAAkB,OAAO,CAAC;AAChC,QAAM,iBAAiB,OAAO,CAAC;AAC/B,QAAM,eAAe,OAAO,KAAK;AACjC,QAAM,eAAe,OAAO,KAAK;AAEjC,QAAM,oBAAoB;AAAA,IACxB,CAAC,EAAE,YAAY,QAAQ,OAAO,MAA6B;AACzD,mBAAa,UAAU;AAEvB,UAAI,CAAC,WAAW,iBAAiB,aAAa,SAAS;AACrD;AAAA,MACF;AAEA,UACE,cAAc,YAAY,cAC1B,UAAU,YAAY,QACtB;AACA;AAAA,MACF;AAEA,YAAM,aAAa,aAAa,OAAO,QAAQ,OAAO;AAEtD,UAAI,cAAc,GAAG;AACnB;AAAA,MACF;AAEA,YAAM,SAAS,0BAA0B;AAAA,QACvC;AAAA,QACA,cAAc,gBAAgB;AAAA,QAC9B,aAAa,eAAe;AAAA,QAC5B,YAAY,QAAQ,UAAU;AAAA,MAChC,CAAC;AAED,mBAAa,UAAU;AAEvB,UAAI,WAAW,MAAM;AACnB,mBAAW;AAAA,UACT,aACI,EAAE,GAAG,QAAQ,UAAU,MAAM,IAC7B,EAAE,GAAG,QAAQ,UAAU,MAAM;AAAA,QACnC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,2BAA2B,iBAAiB,MAAM;AACtD,iBAAa,UAAU;AAAA,EACzB,CAAC;AAED,QAAM,eAAe,iBAAiB,MAAM;AAC1C,UAAM,aAAa,cAAc;AACjC,UAAM,SAAS,UAAU;AAEzB,QACE,CAAC,WACD,iBACA,aAAa,WACb,aAAa,SACb;AACA;AAAA,IACF;AAEA,QACE,CAAC,cACD,CAAC,UACD,gBAAgB,WAAW,KAC3B,eAAe,WAAW,GAC1B;AACA;AAAA,IACF;AAEA,UAAM,mBAAmB,WAAW,mBAAmB;AAEvD,QAAI,oBAAoB,MAAM;AAC5B;AAAA,IACF;AAEA,iBAAa,UAAU;AACvB,WAAO;AAAA,MACL;AAAA,MACA,CAAC,GAAG,GAAG,OAAO,WAAW;AACvB,0BAAkB;AAAA,UAChB;AAAA,UACA;AAAA,UACA,QAAQ,EAAE,GAAG,GAAG,OAAO,OAAO;AAAA,QAChC,CAAC;AAAA,MACH;AAAA,MACA;AAAA,IACF;AAAA,EACF,CAAC;AAED,QAAM,eAAe,iBAAiB,CAAC,UAA6B;AAClE,oBAAgB,UAAU,aACtB,MAAM,YAAY,OAAO,QACzB,MAAM,YAAY,OAAO;AAE7B,iBAAa;AACb,eAAW,KAAK;AAAA,EAClB,CAAC;AAED,QAAM,0BAA0B;AAAA,IAC9B,CAAC,OAAe,WAAmB;AACjC,qBAAe,UAAU,aAAa,QAAQ;AAE9C,mBAAa;AACb,4BAAsB,OAAO,MAAM;AAAA,IACrC;AAAA,EACF;AAEA,QAAM,wBAAwB;AAAA,IAC5B,CAAC,UAAmD;AAClD,mBAAa,UAAU;AAEvB,0BAAoB,KAAK;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,qBAAqB;AAAA,IACrB,mBAAmB;AAAA,EACrB;AACF;","names":[]}
@@ -0,0 +1,4 @@
1
+ export { ScrollView, ScrollViewProps } from 'react-native';
2
+ export { useScrollViewInitialScroll } from './hooks/use-scroll-view-initial-scroll.hook.mjs';
3
+ export { UseScrollViewInitialScrollOptions } from './types/use-scroll-view-initial-scroll.types.mjs';
4
+ import 'react';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { ScrollView } from "react-native";
2
+ export * from "./hooks";
3
+ export * from "./types";
4
+ export {
5
+ ScrollView
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { ScrollView } from \"react-native\";\nexport * from \"./hooks\";\nexport * from \"./types\";\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,2 @@
1
+ export { ScrollViewProps } from 'react-native';
2
+ export { UseScrollViewInitialScrollOptions } from './use-scroll-view-initial-scroll.types.mjs';
@@ -0,0 +1,2 @@
1
+ export * from "./use-scroll-view-initial-scroll.types";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["export type { ScrollViewProps } from \"react-native\";\nexport * from \"./use-scroll-view-initial-scroll.types\";\n"],"mappings":"AACA,cAAc;","names":[]}
@@ -0,0 +1,15 @@
1
+ import { ScrollView, View, LayoutRectangle } from 'react-native';
2
+
3
+ interface ScrollViewMeasurement {
4
+ scrollView: ScrollView;
5
+ target: View;
6
+ layout: LayoutRectangle;
7
+ }
8
+ interface ScrollViewRevealOptions {
9
+ layout: LayoutRectangle;
10
+ viewportSize: number;
11
+ contentSize: number;
12
+ horizontal: boolean;
13
+ }
14
+
15
+ export type { ScrollViewMeasurement, ScrollViewRevealOptions };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=scroll-view-measurement.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,8 @@
1
+ import { ScrollViewProps } from 'react-native';
2
+
3
+ interface UseScrollViewInitialScrollOptions extends Pick<ScrollViewProps, "horizontal" | "contentOffset" | "onLayout" | "onContentSizeChange" | "onScrollBeginDrag"> {
4
+ /** Reveal the target once per mount. Explicit contentOffset takes precedence. */
5
+ enabled?: boolean;
6
+ }
7
+
8
+ export type { UseScrollViewInitialScrollOptions };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=use-scroll-view-initial-scroll.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,4 @@
1
+ /** Move only as far as needed; oversized children align at their leading edge. */
2
+ declare function getRevealOffset(start: number, size: number, viewport: number, content: number, initialOffset: number): number;
3
+
4
+ export { getRevealOffset };
@@ -0,0 +1,11 @@
1
+ function getRevealOffset(start, size, viewport, content, initialOffset) {
2
+ if (size > viewport) {
3
+ return Math.max(0, Math.min(start, content - viewport));
4
+ }
5
+ const offset = start < initialOffset ? start : Math.max(initialOffset, start + size - viewport);
6
+ return Math.max(0, Math.min(offset, content - viewport));
7
+ }
8
+ export {
9
+ getRevealOffset
10
+ };
11
+ //# sourceMappingURL=get-reveal-offset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-reveal-offset.ts"],"sourcesContent":["/** Move only as far as needed; oversized children align at their leading edge. */\nexport function getRevealOffset(\n start: number,\n size: number,\n viewport: number,\n content: number,\n initialOffset: number,\n): number {\n if (size > viewport) {\n return Math.max(0, Math.min(start, content - viewport));\n }\n\n const offset =\n start < initialOffset\n ? start\n : Math.max(initialOffset, start + size - viewport);\n\n return Math.max(0, Math.min(offset, content - viewport));\n}\n"],"mappings":"AACO,SAAS,gBACd,OACA,MACA,UACA,SACA,eACQ;AACR,MAAI,OAAO,UAAU;AACnB,WAAO,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,UAAU,QAAQ,CAAC;AAAA,EACxD;AAEA,QAAM,SACJ,QAAQ,gBACJ,QACA,KAAK,IAAI,eAAe,QAAQ,OAAO,QAAQ;AAErD,SAAO,KAAK,IAAI,GAAG,KAAK,IAAI,QAAQ,UAAU,QAAQ,CAAC;AACzD;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { ScrollViewRevealOptions } from '../types/scroll-view-measurement.types.mjs';
2
+ import 'react-native';
3
+
4
+ /** Returns null when the target is already visible at the native initial offset. */
5
+ declare function getScrollViewRevealOffset({ layout, viewportSize, contentSize, horizontal, }: ScrollViewRevealOptions): number | null;
6
+
7
+ export { getScrollViewRevealOffset };
@@ -0,0 +1,16 @@
1
+ import { getRevealOffset } from "./get-reveal-offset";
2
+ function getScrollViewRevealOffset({
3
+ layout,
4
+ viewportSize,
5
+ contentSize,
6
+ horizontal
7
+ }) {
8
+ const size = horizontal ? layout.width : layout.height;
9
+ const start = horizontal ? layout.x : layout.y;
10
+ const offset = getRevealOffset(start, size, viewportSize, contentSize, 0);
11
+ return offset === 0 ? null : offset;
12
+ }
13
+ export {
14
+ getScrollViewRevealOffset
15
+ };
16
+ //# sourceMappingURL=get-scroll-view-reveal-offset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/get-scroll-view-reveal-offset.ts"],"sourcesContent":["import type { ScrollViewRevealOptions } from \"../types/scroll-view-measurement.types\";\nimport { getRevealOffset } from \"./get-reveal-offset\";\n\n/** Returns null when the target is already visible at the native initial offset. */\nexport function getScrollViewRevealOffset({\n layout,\n viewportSize,\n contentSize,\n horizontal,\n}: ScrollViewRevealOptions): number | null {\n const size = horizontal ? layout.width : layout.height;\n const start = horizontal ? layout.x : layout.y;\n const offset = getRevealOffset(start, size, viewportSize, contentSize, 0);\n\n return offset === 0 ? null : offset;\n}\n"],"mappings":"AACA,SAAS,uBAAuB;AAGzB,SAAS,0BAA0B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA2C;AACzC,QAAM,OAAO,aAAa,OAAO,QAAQ,OAAO;AAChD,QAAM,QAAQ,aAAa,OAAO,IAAI,OAAO;AAC7C,QAAM,SAAS,gBAAgB,OAAO,MAAM,cAAc,aAAa,CAAC;AAExE,SAAO,WAAW,IAAI,OAAO;AAC/B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@impulse-ui-native/scroll-view",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "9.0.0",
4
+ "description": "Native ScrollView and a small hook to reveal an initially selected child.",
5
+ "keywords": [
6
+ "react-native",
7
+ "scroll-view",
8
+ "scroll"
9
+ ],
10
+ "license": "MIT",
11
+ "source": "src/index.ts",
12
+ "module": "dist/index.js",
13
+ "types": "dist/index.d.mts",
14
+ "react-native": "src/index.ts",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.mts",
18
+ "react-native": "./src/index.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "sideEffects": false,
28
+ "devDependencies": {
29
+ "@types/react": "~19.2.14",
30
+ "eslint": "^9.38.0",
31
+ "prettier": "^3.6.2",
32
+ "react": "19.2.3",
33
+ "react-native": "0.86.2",
34
+ "typescript": "~6.0.3",
35
+ "@impulse-ui-native/eslint-config": "1.0.0",
36
+ "@impulse-ui-native/prettier-config": "1.0.0",
37
+ "@impulse-ui-native/tsconfig": "1.0.0"
38
+ },
39
+ "peerDependencies": {
40
+ "react": ">=18",
41
+ "react-native": ">=0.73"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "prettier": "@impulse-ui-native/prettier-config",
47
+ "dependencies": {
48
+ "@impulse-ui-native/core": "9.0.0"
49
+ },
50
+ "scripts": {
51
+ "build": "tsup --config tsup.config.ts",
52
+ "typecheck": "tsc -p tsconfig.json --noEmit",
53
+ "lint": "pnpm exec eslint . --fix",
54
+ "format": "prettier --write \"./**/*.{ts,tsx,js,jsx,json,md}\" --ignore-path ../../.prettierignore"
55
+ }
6
56
  }