gsap-react-marquee 0.1.3 → 0.1.4
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/components/gsap-react-marquee.type.d.ts +2 -1
- package/dist/components/gsap-reactmarquee.utils.d.ts +72 -3
- package/dist/index.cjs.js +1006 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +74 -4
- package/dist/index.esm.js +1006 -42
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -87,8 +87,9 @@ type GSAPReactMarqueeProps = {
|
|
|
87
87
|
*/
|
|
88
88
|
followScrollDir?: boolean;
|
|
89
89
|
/**
|
|
90
|
-
* @description Speed factor when syncing with page scroll
|
|
90
|
+
* @description Speed factor when syncing with page scroll, max value is 4
|
|
91
91
|
* @type {number}
|
|
92
|
+
* @default 2.5
|
|
92
93
|
*/
|
|
93
94
|
scrollSpeed?: number;
|
|
94
95
|
};
|
|
@@ -97,22 +98,91 @@ declare const GSAPReactMarquee: react.ForwardRefExoticComponent<GSAPReactMarquee
|
|
|
97
98
|
|
|
98
99
|
/**
|
|
99
100
|
* Utility function to merge Tailwind classes with clsx
|
|
101
|
+
*
|
|
102
|
+
* Combines clsx for conditional classes with tailwind-merge to handle
|
|
103
|
+
* conflicting Tailwind classes by keeping the last occurrence.
|
|
104
|
+
* This prevents issues like "p-4 p-2" where both would be applied.
|
|
105
|
+
*
|
|
106
|
+
* @param inputs - Array of class values (strings, conditionals, objects)
|
|
107
|
+
* @returns Merged and deduplicated class string
|
|
100
108
|
*/
|
|
101
109
|
declare const cn: (...inputs: ClassValue[]) => string;
|
|
102
110
|
/**
|
|
103
|
-
* Sets up container styles and rotation handling
|
|
111
|
+
* Sets up container styles and rotation handling for the marquee
|
|
112
|
+
*
|
|
113
|
+
* This function handles the complex styling requirements for different marquee orientations:
|
|
114
|
+
*
|
|
115
|
+
* 1. **Basic Setup**: Applies gap spacing and rotation for vertical marquees
|
|
116
|
+
* 2. **Vertical Mode**: Rotates container 90° and adjusts width to parent height
|
|
117
|
+
* 3. **Rotation Alignment**: Special mode for vertical text that remains readable
|
|
118
|
+
*
|
|
119
|
+
* @param containerMarquee - The main container element that holds all marquee instances
|
|
120
|
+
* @param marquees - Array of individual marquee wrapper elements
|
|
121
|
+
* @param marqueesChildren - Array of content container elements within each marquee
|
|
122
|
+
* @param isVertical - Boolean indicating if marquee moves up/down instead of left/right
|
|
123
|
+
* @param props - Configuration object containing spacing and alignment options
|
|
104
124
|
*/
|
|
105
125
|
declare const setupContainerStyles: (containerMarquee: HTMLElement, marquees: HTMLElement[], marqueesChildren: HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
|
|
106
126
|
/**
|
|
107
|
-
* Calculates the number of duplicates needed
|
|
127
|
+
* Calculates the number of content duplicates needed for seamless looping
|
|
128
|
+
*
|
|
129
|
+
* For smooth infinite scrolling, we need enough content copies to fill the visible area
|
|
130
|
+
* plus buffer space. This prevents gaps when content loops back to the beginning.
|
|
131
|
+
*
|
|
132
|
+
* Algorithm:
|
|
133
|
+
* 1. If not in fill mode, only one copy is needed (content already spans container)
|
|
134
|
+
* 2. Determine target width (viewport height for vertical, container width for horizontal)
|
|
135
|
+
* 3. Calculate how many copies fit in the target space, rounding up for complete coverage
|
|
136
|
+
*
|
|
137
|
+
* @param marqueeChildrenWidth - Width of a single content instance
|
|
138
|
+
* @param containerMarqueeWidth - Width of the marquee container
|
|
139
|
+
* @param isVertical - Whether the marquee scrolls vertically
|
|
140
|
+
* @param props - Configuration object containing fill mode setting
|
|
141
|
+
* @returns Number of content duplicates needed (minimum 1)
|
|
108
142
|
*/
|
|
109
143
|
declare const calculateDuplicates: (marqueeChildrenWidth: number, containerMarqueeWidth: number, isVertical: boolean, props: GSAPReactMarqueeProps) => number;
|
|
110
144
|
/**
|
|
111
|
-
* Determines the minimum width for marquee elements
|
|
145
|
+
* Determines the minimum width for marquee elements based on content and container
|
|
146
|
+
*
|
|
147
|
+
* This function ensures marquee elements have appropriate dimensions for their content
|
|
148
|
+
* and container context, handling different modes and orientations.
|
|
149
|
+
*
|
|
150
|
+
* Width determination logic:
|
|
151
|
+
* 1. **Fill mode**: Auto width lets content size naturally
|
|
152
|
+
* 2. **Rotation alignment**: Use content height as width (rotated dimensions)
|
|
153
|
+
* 3. **Undersized content**: Stretch to 100% to fill container
|
|
154
|
+
* 4. **Oversized content**: Use actual content width for overflow scrolling
|
|
155
|
+
*
|
|
156
|
+
* @param marqueesChildren - Array of content elements for dimension measurement
|
|
157
|
+
* @param totalWidth - Combined width of all content elements
|
|
158
|
+
* @param containerMarqueeWidth - Available container width
|
|
159
|
+
* @param props - Configuration object containing fill and alignment settings
|
|
160
|
+
* @returns CSS width value (string with units or number for pixels)
|
|
112
161
|
*/
|
|
113
162
|
declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth: number, containerMarqueeWidth: number, props: GSAPReactMarqueeProps) => string | number;
|
|
114
163
|
/**
|
|
115
164
|
* Creates a complex fill-based marquee animation with seamless looping
|
|
165
|
+
*
|
|
166
|
+
* This is the core animation engine that creates smooth, continuous scrolling.
|
|
167
|
+
* It handles the complex math required for seamless looping by calculating
|
|
168
|
+
* precise positions and durations for each content element.
|
|
169
|
+
*
|
|
170
|
+
* Animation Strategy:
|
|
171
|
+
* 1. **Position Calculation**: Convert pixel positions to percentages for responsive scaling
|
|
172
|
+
* 2. **Seamless Looping**: Calculate track length and loop points to prevent gaps
|
|
173
|
+
* 3. **Staggered Animation**: Each element starts at different times for smooth flow
|
|
174
|
+
* 4. **Direction Handling**: Support forward and reverse directions with proper timing
|
|
175
|
+
*
|
|
176
|
+
* Technical Details:
|
|
177
|
+
* - Uses xPercent for percentage-based positioning (responsive to element width changes)
|
|
178
|
+
* - Creates two-part animation: main movement + seamless loop reset
|
|
179
|
+
* - Calculates precise durations based on distance and speed for consistent motion
|
|
180
|
+
*
|
|
181
|
+
* @param elementsToAnimate - Array of DOM elements to animate (content or containers)
|
|
182
|
+
* @param startX - Starting X position reference point
|
|
183
|
+
* @param tl - GSAP timeline to add animations to
|
|
184
|
+
* @param isReverse - Whether animation should play in reverse direction
|
|
185
|
+
* @param props - Configuration object with spacing, speed, delay, and other settings
|
|
116
186
|
*/
|
|
117
187
|
declare const coreAnimation: (elementsToAnimate: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, props: GSAPReactMarqueeProps) => void;
|
|
118
188
|
|