rune-scroller 2.2.1 → 3.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/dist/types.js DELETED
@@ -1,48 +0,0 @@
1
- /**
2
- * Centralized type definitions for Rune Scroller library
3
- * All types are defined here for consistency and ease of maintenance
4
- */
5
-
6
- /**
7
- * Animation type names available in Rune Scroller
8
- * @typedef {'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'zoom-in-up' | 'zoom-in-left' | 'zoom-in-right' | 'flip' | 'flip-x' | 'slide-rotate' | 'bounce-in'} AnimationType
9
- */
10
-
11
- /**
12
- * Options for the runeScroller action
13
- * Sentinel-based scroll animation triggering
14
- *
15
- * @typedef {Object} RuneScrollerOptions
16
- * @property {AnimationType} [animation='fade-in'] - Animation type to apply
17
- * @property {number} [duration=2500] - Animation duration in milliseconds
18
- * @property {boolean} [repeat=false] - Repeat animation on every scroll
19
- * @property {boolean} [debug=false] - Show sentinel as visible line for debugging
20
- * @property {string} [sentinelColor='#00e0ff'] - Sentinel color for debug mode (hex or CSS color)
21
- * @property {string} [sentinelId] - Unique identifier for sentinel (auto-generated if not provided)
22
- * @property {string} [debugLabel] - Debug label to show on sentinel (e.g., animation name)
23
- * @property {number} [offset=0] - Offset of sentinel in pixels (negative = above element)
24
- * @property {(element: HTMLElement) => void} [onVisible] - Callback fired when animation becomes visible
25
- */
26
-
27
-
28
-
29
- /**
30
- * Configuration options for IntersectionObserver
31
- * Used by useIntersection and useIntersectionOnce composables
32
- *
33
- * @typedef {Object} IntersectionOptions
34
- * @property {number | number[]} [threshold] - IntersectionObserver threshold
35
- * @property {string} [rootMargin] - Custom margin around root element
36
- * @property {Element | null} [root] - Root element for intersection observation
37
- */
38
-
39
- /**
40
- * Return type for useIntersection and useIntersectionOnce composables
41
- * Provides reactive element reference and visibility state
42
- *
43
- * @typedef {Object} UseIntersectionReturn
44
- * @property {HTMLElement | null} element - Reference to the DOM element being observed
45
- * @property {boolean} isVisible - Whether the element is currently visible in viewport
46
- */
47
-
48
- export {};
@@ -1,11 +0,0 @@
1
- /**
2
- * @param {import('./types.js').IntersectionOptions} [options={}]
3
- * @param {(isVisible: boolean) => void} [onVisible]
4
- * @returns {import('./types.js').UseIntersectionReturn}
5
- */
6
- export function useIntersection(options?: import("./types.js").IntersectionOptions, onVisible?: (isVisible: boolean) => void): import("./types.js").UseIntersectionReturn;
7
- /**
8
- * @param {import('./types.js').IntersectionOptions} [options={}]
9
- * @returns {import('./types.js').UseIntersectionReturn}
10
- */
11
- export function useIntersectionOnce(options?: import("./types.js").IntersectionOptions): import("./types.js").UseIntersectionReturn;
@@ -1,90 +0,0 @@
1
- /**
2
- * Composable for handling IntersectionObserver logic
3
- * Reduces duplication between animation components
4
- */
5
-
6
- /**
7
- * @param {import('./types.js').IntersectionOptions} [options={}]
8
- * @param {((entry: IntersectionObserverEntry, isVisible: boolean) => void) | undefined} onIntersect
9
- * @param {boolean} [once=false]
10
- * @returns {import('./types.js').UseIntersectionReturn}
11
- */
12
- function createIntersectionObserver(options = {}, onIntersect = undefined, once = false) {
13
- const { threshold = 0.5, rootMargin = '-10% 0px -10% 0px', root = null } = options;
14
-
15
- let element = $state(null);
16
- let isVisible = $state(false);
17
- let hasTriggeredOnce = false;
18
- /** @type {IntersectionObserver | null} */
19
- let observer = null;
20
-
21
- $effect(() => {
22
- if (!element) return;
23
-
24
- observer = new IntersectionObserver(
25
- (entries) => {
26
- entries.forEach((entry) => {
27
- // For once-only behavior, check if already triggered
28
- if (once && hasTriggeredOnce) return;
29
-
30
- isVisible = entry.isIntersecting;
31
- if (onIntersect) {
32
- onIntersect(entry, entry.isIntersecting);
33
- }
34
-
35
- // Unobserve after first trigger if once=true
36
- if (once && entry.isIntersecting) {
37
- hasTriggeredOnce = true;
38
- observer?.unobserve(entry.target);
39
- }
40
- });
41
- },
42
- {
43
- threshold,
44
- rootMargin,
45
- root
46
- }
47
- );
48
-
49
- observer.observe(element);
50
-
51
- return () => {
52
- observer?.disconnect();
53
- };
54
- });
55
-
56
- return {
57
- get element() {
58
- return element;
59
- },
60
- set element(value) {
61
- element = value;
62
- },
63
- get isVisible() {
64
- return isVisible;
65
- }
66
- };
67
- }
68
-
69
- /**
70
- * @param {import('./types.js').IntersectionOptions} [options={}]
71
- * @param {(isVisible: boolean) => void} [onVisible]
72
- * @returns {import('./types.js').UseIntersectionReturn}
73
- */
74
- export function useIntersection(options = {}, onVisible) {
75
- return createIntersectionObserver(
76
- options,
77
- (_entry, isVisible) => {
78
- onVisible?.(isVisible);
79
- },
80
- false
81
- );
82
- }
83
-
84
- /**
85
- * @param {import('./types.js').IntersectionOptions} [options={}]
86
- * @returns {import('./types.js').UseIntersectionReturn}
87
- */
88
- export function useIntersectionOnce(options = {}) {
89
- return createIntersectionObserver(options, () => {}, true);
90
- }