react-sway 0.1.0 → 0.2.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 +109 -0
- package/dist/index.cjs +314 -209
- package/dist/index.d.cts +55 -2
- package/dist/index.d.ts +55 -2
- package/dist/index.js +315 -210
- package/package.json +18 -12
- package/src/ReactSway.tsx +445 -247
- package/src/__tests__/ReactSway.test.tsx +508 -0
- package/src/__tests__/setup.ts +20 -0
- package/src/index.ts +5 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,62 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Props for the ReactSway infinite scrolling component.
|
|
6
|
+
*/
|
|
4
7
|
interface ReactSwayProps {
|
|
8
|
+
/** Enable/disable auto-scrolling. @default true */
|
|
9
|
+
autoScroll?: boolean;
|
|
10
|
+
/** Content elements to render in the infinite scroll container. */
|
|
5
11
|
children: ReactNode;
|
|
12
|
+
/** Auto-scroll direction. @default 'up' */
|
|
13
|
+
direction?: 'down' | 'up';
|
|
14
|
+
/** Enable mouse/touch drag interaction. @default true */
|
|
15
|
+
draggable?: boolean;
|
|
16
|
+
/** Momentum decay coefficient (0-1, lower = more friction). @default 0.95 */
|
|
17
|
+
friction?: number;
|
|
18
|
+
/** Enable keyboard controls (Space, ArrowUp/Down, Home/End). @default true */
|
|
19
|
+
keyboard?: boolean;
|
|
20
|
+
/** Enable lazy visibility detection via IntersectionObserver. @default true */
|
|
21
|
+
lazy?: boolean;
|
|
22
|
+
/** IntersectionObserver rootMargin for lazy visibility detection. @default '100px' */
|
|
23
|
+
lazyRootMargin?: string;
|
|
24
|
+
/** IntersectionObserver threshold for lazy visibility detection. @default 0.01 */
|
|
25
|
+
lazyThreshold?: number;
|
|
26
|
+
/** Fired when scrolling pauses (user interaction or Space key). */
|
|
27
|
+
onPause?: () => void;
|
|
28
|
+
/** Fired when scrolling resumes after pause. */
|
|
29
|
+
onResume?: () => void;
|
|
30
|
+
/** Fired on every position change with the current scroll position. */
|
|
31
|
+
onScroll?: (position: number) => void;
|
|
32
|
+
/** Pause auto-scroll during user interaction. @default true */
|
|
33
|
+
pauseOnInteraction?: boolean;
|
|
34
|
+
/** Milliseconds before auto-scroll resumes after interaction. @default 2000 */
|
|
35
|
+
resumeDelay?: number;
|
|
36
|
+
/** Auto-scroll speed in pixels per frame at 60fps. @default 0.5 */
|
|
37
|
+
speed?: number;
|
|
38
|
+
/** Enable mouse wheel scrolling. @default true */
|
|
39
|
+
wheelEnabled?: boolean;
|
|
6
40
|
}
|
|
7
|
-
|
|
41
|
+
/**
|
|
42
|
+
* A smooth, infinite scrolling container component.
|
|
43
|
+
*
|
|
44
|
+
* Renders children in a continuously looping scroll area with support for
|
|
45
|
+
* auto-scrolling, mouse drag, touch swipe, wheel, and keyboard interactions.
|
|
46
|
+
* Content is duplicated to create a seamless loop effect. Duplicate content
|
|
47
|
+
* is wrapped in `<aside>` elements with `aria-hidden="true"` for accessibility.
|
|
48
|
+
*
|
|
49
|
+
* Respects `prefers-reduced-motion: reduce` by lowering auto-scroll speed
|
|
50
|
+
* and disabling momentum effects.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <ReactSway direction="up" speed={1} friction={0.9}>
|
|
55
|
+
* <div className="content-item">Item 1</div>
|
|
56
|
+
* <div className="content-item">Item 2</div>
|
|
57
|
+
* </ReactSway>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function ReactSway({ autoScroll, children, direction, draggable, friction, keyboard, lazy, lazyRootMargin, lazyThreshold, onPause, onResume, onScroll, pauseOnInteraction, resumeDelay, speed, wheelEnabled, }: ReactSwayProps): react_jsx_runtime.JSX.Element;
|
|
8
61
|
|
|
9
|
-
export { ReactSway };
|
|
62
|
+
export { ReactSway, type ReactSwayProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,62 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Props for the ReactSway infinite scrolling component.
|
|
6
|
+
*/
|
|
4
7
|
interface ReactSwayProps {
|
|
8
|
+
/** Enable/disable auto-scrolling. @default true */
|
|
9
|
+
autoScroll?: boolean;
|
|
10
|
+
/** Content elements to render in the infinite scroll container. */
|
|
5
11
|
children: ReactNode;
|
|
12
|
+
/** Auto-scroll direction. @default 'up' */
|
|
13
|
+
direction?: 'down' | 'up';
|
|
14
|
+
/** Enable mouse/touch drag interaction. @default true */
|
|
15
|
+
draggable?: boolean;
|
|
16
|
+
/** Momentum decay coefficient (0-1, lower = more friction). @default 0.95 */
|
|
17
|
+
friction?: number;
|
|
18
|
+
/** Enable keyboard controls (Space, ArrowUp/Down, Home/End). @default true */
|
|
19
|
+
keyboard?: boolean;
|
|
20
|
+
/** Enable lazy visibility detection via IntersectionObserver. @default true */
|
|
21
|
+
lazy?: boolean;
|
|
22
|
+
/** IntersectionObserver rootMargin for lazy visibility detection. @default '100px' */
|
|
23
|
+
lazyRootMargin?: string;
|
|
24
|
+
/** IntersectionObserver threshold for lazy visibility detection. @default 0.01 */
|
|
25
|
+
lazyThreshold?: number;
|
|
26
|
+
/** Fired when scrolling pauses (user interaction or Space key). */
|
|
27
|
+
onPause?: () => void;
|
|
28
|
+
/** Fired when scrolling resumes after pause. */
|
|
29
|
+
onResume?: () => void;
|
|
30
|
+
/** Fired on every position change with the current scroll position. */
|
|
31
|
+
onScroll?: (position: number) => void;
|
|
32
|
+
/** Pause auto-scroll during user interaction. @default true */
|
|
33
|
+
pauseOnInteraction?: boolean;
|
|
34
|
+
/** Milliseconds before auto-scroll resumes after interaction. @default 2000 */
|
|
35
|
+
resumeDelay?: number;
|
|
36
|
+
/** Auto-scroll speed in pixels per frame at 60fps. @default 0.5 */
|
|
37
|
+
speed?: number;
|
|
38
|
+
/** Enable mouse wheel scrolling. @default true */
|
|
39
|
+
wheelEnabled?: boolean;
|
|
6
40
|
}
|
|
7
|
-
|
|
41
|
+
/**
|
|
42
|
+
* A smooth, infinite scrolling container component.
|
|
43
|
+
*
|
|
44
|
+
* Renders children in a continuously looping scroll area with support for
|
|
45
|
+
* auto-scrolling, mouse drag, touch swipe, wheel, and keyboard interactions.
|
|
46
|
+
* Content is duplicated to create a seamless loop effect. Duplicate content
|
|
47
|
+
* is wrapped in `<aside>` elements with `aria-hidden="true"` for accessibility.
|
|
48
|
+
*
|
|
49
|
+
* Respects `prefers-reduced-motion: reduce` by lowering auto-scroll speed
|
|
50
|
+
* and disabling momentum effects.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```tsx
|
|
54
|
+
* <ReactSway direction="up" speed={1} friction={0.9}>
|
|
55
|
+
* <div className="content-item">Item 1</div>
|
|
56
|
+
* <div className="content-item">Item 2</div>
|
|
57
|
+
* </ReactSway>
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
declare function ReactSway({ autoScroll, children, direction, draggable, friction, keyboard, lazy, lazyRootMargin, lazyThreshold, onPause, onResume, onScroll, pauseOnInteraction, resumeDelay, speed, wheelEnabled, }: ReactSwayProps): react_jsx_runtime.JSX.Element;
|
|
8
61
|
|
|
9
|
-
export { ReactSway };
|
|
62
|
+
export { ReactSway, type ReactSwayProps };
|