gsap-react-marquee 0.1.4 → 0.1.7
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 +1 -1
- package/dist/components/gsap-reactmarquee.utils.d.ts +32 -2
- package/dist/index.cjs.css +1 -1
- package/dist/index.cjs.js +4553 -585
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +33 -3
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.js +4554 -587
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,4 +45,4 @@ function App() {
|
|
|
45
45
|
| `spacing` | `number` | `16` | Spacing between repeated elements in px |
|
|
46
46
|
| `draggable` | `boolean` | `false` | Enable dragging to scroll manually |
|
|
47
47
|
| `followScrollDir` | `boolean` | `false` | Sync marquee with page scroll direction |
|
|
48
|
-
| `scrollSpeed` | `number` |
|
|
48
|
+
| `scrollSpeed` | `number` | `2.5` | Speed factor when syncing with page scroll |
|
|
@@ -11,6 +11,32 @@ import type { GSAPReactMarqueeProps } from "./gsap-react-marquee.type";
|
|
|
11
11
|
* @returns Merged and deduplicated class string
|
|
12
12
|
*/
|
|
13
13
|
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Traverses the DOM tree upward to find the first non-transparent background color
|
|
16
|
+
*
|
|
17
|
+
* This function walks up the element hierarchy starting from the given element,
|
|
18
|
+
* checking each parent's computed backgroundColor style until it finds a visible
|
|
19
|
+
* (non-transparent) background color. This is useful for automatically detecting
|
|
20
|
+
* the effective background behind an element for gradient overlays.
|
|
21
|
+
*
|
|
22
|
+
* The traversal stops at the first element with a visible background color,
|
|
23
|
+
* which could be the element itself or any of its ancestors up to the document root.
|
|
24
|
+
*
|
|
25
|
+
* @param el - The HTMLElement to start the background color search from
|
|
26
|
+
* @returns The first non-transparent background color found in the hierarchy,
|
|
27
|
+
* or "transparent" if no visible background is found
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Element with white parent background
|
|
31
|
+
* const color = getEffectiveBackgroundColor(marqueeElement);
|
|
32
|
+
* // Returns: "rgb(255, 255, 255)" or "#ffffff"
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // Element with no background set anywhere in hierarchy
|
|
36
|
+
* const color = getEffectiveBackgroundColor(marqueeElement);
|
|
37
|
+
* // Returns: "transparent"
|
|
38
|
+
*/
|
|
39
|
+
export declare const getEffectiveBackgroundColor: (el: HTMLElement) => string;
|
|
14
40
|
/**
|
|
15
41
|
* Sets up container styles and rotation handling for the marquee
|
|
16
42
|
*
|
|
@@ -65,7 +91,7 @@ export declare const calculateDuplicates: (marqueeChildrenWidth: number, contain
|
|
|
65
91
|
*/
|
|
66
92
|
export declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth: number, containerMarqueeWidth: number, props: GSAPReactMarqueeProps) => string | number;
|
|
67
93
|
/**
|
|
68
|
-
* Creates a complex
|
|
94
|
+
* Creates a complex marquee animation with seamless looping and draggable support
|
|
69
95
|
*
|
|
70
96
|
* This is the core animation engine that creates smooth, continuous scrolling.
|
|
71
97
|
* It handles the complex math required for seamless looping by calculating
|
|
@@ -76,16 +102,20 @@ export declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth:
|
|
|
76
102
|
* 2. **Seamless Looping**: Calculate track length and loop points to prevent gaps
|
|
77
103
|
* 3. **Staggered Animation**: Each element starts at different times for smooth flow
|
|
78
104
|
* 4. **Direction Handling**: Support forward and reverse directions with proper timing
|
|
105
|
+
* 5. **Integrated Draggable**: Optional support for drag interaction with manual control
|
|
79
106
|
*
|
|
80
107
|
* Technical Details:
|
|
81
108
|
* - Uses xPercent for percentage-based positioning (responsive to element width changes)
|
|
82
109
|
* - Creates two-part animation: main movement + seamless loop reset
|
|
83
110
|
* - Calculates precise durations based on distance and speed for consistent motion
|
|
111
|
+
* - Implements draggable with intelligent pause/resume animation handling
|
|
84
112
|
*
|
|
85
113
|
* @param elementsToAnimate - Array of DOM elements to animate (content or containers)
|
|
86
114
|
* @param startX - Starting X position reference point
|
|
87
115
|
* @param tl - GSAP timeline to add animations to
|
|
88
116
|
* @param isReverse - Whether animation should play in reverse direction
|
|
117
|
+
* @param draggableTrigger - Element(s) that will trigger the draggable functionality
|
|
118
|
+
* @param isVertical - Whether the marquee scrolls vertically
|
|
89
119
|
* @param props - Configuration object with spacing, speed, delay, and other settings
|
|
90
120
|
*/
|
|
91
|
-
export declare const coreAnimation: (elementsToAnimate: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, props: GSAPReactMarqueeProps) => void;
|
|
121
|
+
export declare const coreAnimation: (elementsToAnimate: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, draggableTrigger: HTMLElement | HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
|
package/dist/index.cjs.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.gsap-react-marquee{flex:1;height:max-content;width:auto}.gsap-react-marquee,.gsap-react-marquee-content{display:flex;line-height:100%;white-space:preserve nowrap}.gsap-react-marquee-content{overflow:hidden;width:max-content}
|
|
1
|
+
.gsap-react-marquee-container:after{background:linear-gradient(270deg,hsla(0,0%,100%,0) 0,var(--gradient-color) 75%);left:0}.gsap-react-marquee-container:after,.gsap-react-marquee-container:before{content:"";height:100%;pointer-events:none;position:absolute;top:0;width:15%;z-index:10}.gsap-react-marquee-container:before{background:linear-gradient(90deg,hsla(0,0%,100%,0) 0,var(--gradient-color) 75%);right:0}.gsap-react-marquee{flex:1;height:max-content;width:auto}.gsap-react-marquee,.gsap-react-marquee-content{display:flex;line-height:100%;white-space:preserve nowrap}.gsap-react-marquee-content{overflow:hidden;width:max-content}
|