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
|
@@ -84,8 +84,9 @@ export type GSAPReactMarqueeProps = {
|
|
|
84
84
|
*/
|
|
85
85
|
followScrollDir?: boolean;
|
|
86
86
|
/**
|
|
87
|
-
* @description Speed factor when syncing with page scroll
|
|
87
|
+
* @description Speed factor when syncing with page scroll, max value is 4
|
|
88
88
|
* @type {number}
|
|
89
|
+
* @default 2.5
|
|
89
90
|
*/
|
|
90
91
|
scrollSpeed?: number;
|
|
91
92
|
};
|
|
@@ -2,21 +2,90 @@ import { type ClassValue } from "clsx";
|
|
|
2
2
|
import type { GSAPReactMarqueeProps } from "./gsap-react-marquee.type";
|
|
3
3
|
/**
|
|
4
4
|
* Utility function to merge Tailwind classes with clsx
|
|
5
|
+
*
|
|
6
|
+
* Combines clsx for conditional classes with tailwind-merge to handle
|
|
7
|
+
* conflicting Tailwind classes by keeping the last occurrence.
|
|
8
|
+
* This prevents issues like "p-4 p-2" where both would be applied.
|
|
9
|
+
*
|
|
10
|
+
* @param inputs - Array of class values (strings, conditionals, objects)
|
|
11
|
+
* @returns Merged and deduplicated class string
|
|
5
12
|
*/
|
|
6
13
|
export declare const cn: (...inputs: ClassValue[]) => string;
|
|
7
14
|
/**
|
|
8
|
-
* Sets up container styles and rotation handling
|
|
15
|
+
* Sets up container styles and rotation handling for the marquee
|
|
16
|
+
*
|
|
17
|
+
* This function handles the complex styling requirements for different marquee orientations:
|
|
18
|
+
*
|
|
19
|
+
* 1. **Basic Setup**: Applies gap spacing and rotation for vertical marquees
|
|
20
|
+
* 2. **Vertical Mode**: Rotates container 90° and adjusts width to parent height
|
|
21
|
+
* 3. **Rotation Alignment**: Special mode for vertical text that remains readable
|
|
22
|
+
*
|
|
23
|
+
* @param containerMarquee - The main container element that holds all marquee instances
|
|
24
|
+
* @param marquees - Array of individual marquee wrapper elements
|
|
25
|
+
* @param marqueesChildren - Array of content container elements within each marquee
|
|
26
|
+
* @param isVertical - Boolean indicating if marquee moves up/down instead of left/right
|
|
27
|
+
* @param props - Configuration object containing spacing and alignment options
|
|
9
28
|
*/
|
|
10
29
|
export declare const setupContainerStyles: (containerMarquee: HTMLElement, marquees: HTMLElement[], marqueesChildren: HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
|
|
11
30
|
/**
|
|
12
|
-
* Calculates the number of duplicates needed
|
|
31
|
+
* Calculates the number of content duplicates needed for seamless looping
|
|
32
|
+
*
|
|
33
|
+
* For smooth infinite scrolling, we need enough content copies to fill the visible area
|
|
34
|
+
* plus buffer space. This prevents gaps when content loops back to the beginning.
|
|
35
|
+
*
|
|
36
|
+
* Algorithm:
|
|
37
|
+
* 1. If not in fill mode, only one copy is needed (content already spans container)
|
|
38
|
+
* 2. Determine target width (viewport height for vertical, container width for horizontal)
|
|
39
|
+
* 3. Calculate how many copies fit in the target space, rounding up for complete coverage
|
|
40
|
+
*
|
|
41
|
+
* @param marqueeChildrenWidth - Width of a single content instance
|
|
42
|
+
* @param containerMarqueeWidth - Width of the marquee container
|
|
43
|
+
* @param isVertical - Whether the marquee scrolls vertically
|
|
44
|
+
* @param props - Configuration object containing fill mode setting
|
|
45
|
+
* @returns Number of content duplicates needed (minimum 1)
|
|
13
46
|
*/
|
|
14
47
|
export declare const calculateDuplicates: (marqueeChildrenWidth: number, containerMarqueeWidth: number, isVertical: boolean, props: GSAPReactMarqueeProps) => number;
|
|
15
48
|
/**
|
|
16
|
-
* Determines the minimum width for marquee elements
|
|
49
|
+
* Determines the minimum width for marquee elements based on content and container
|
|
50
|
+
*
|
|
51
|
+
* This function ensures marquee elements have appropriate dimensions for their content
|
|
52
|
+
* and container context, handling different modes and orientations.
|
|
53
|
+
*
|
|
54
|
+
* Width determination logic:
|
|
55
|
+
* 1. **Fill mode**: Auto width lets content size naturally
|
|
56
|
+
* 2. **Rotation alignment**: Use content height as width (rotated dimensions)
|
|
57
|
+
* 3. **Undersized content**: Stretch to 100% to fill container
|
|
58
|
+
* 4. **Oversized content**: Use actual content width for overflow scrolling
|
|
59
|
+
*
|
|
60
|
+
* @param marqueesChildren - Array of content elements for dimension measurement
|
|
61
|
+
* @param totalWidth - Combined width of all content elements
|
|
62
|
+
* @param containerMarqueeWidth - Available container width
|
|
63
|
+
* @param props - Configuration object containing fill and alignment settings
|
|
64
|
+
* @returns CSS width value (string with units or number for pixels)
|
|
17
65
|
*/
|
|
18
66
|
export declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth: number, containerMarqueeWidth: number, props: GSAPReactMarqueeProps) => string | number;
|
|
19
67
|
/**
|
|
20
68
|
* Creates a complex fill-based marquee animation with seamless looping
|
|
69
|
+
*
|
|
70
|
+
* This is the core animation engine that creates smooth, continuous scrolling.
|
|
71
|
+
* It handles the complex math required for seamless looping by calculating
|
|
72
|
+
* precise positions and durations for each content element.
|
|
73
|
+
*
|
|
74
|
+
* Animation Strategy:
|
|
75
|
+
* 1. **Position Calculation**: Convert pixel positions to percentages for responsive scaling
|
|
76
|
+
* 2. **Seamless Looping**: Calculate track length and loop points to prevent gaps
|
|
77
|
+
* 3. **Staggered Animation**: Each element starts at different times for smooth flow
|
|
78
|
+
* 4. **Direction Handling**: Support forward and reverse directions with proper timing
|
|
79
|
+
*
|
|
80
|
+
* Technical Details:
|
|
81
|
+
* - Uses xPercent for percentage-based positioning (responsive to element width changes)
|
|
82
|
+
* - Creates two-part animation: main movement + seamless loop reset
|
|
83
|
+
* - Calculates precise durations based on distance and speed for consistent motion
|
|
84
|
+
*
|
|
85
|
+
* @param elementsToAnimate - Array of DOM elements to animate (content or containers)
|
|
86
|
+
* @param startX - Starting X position reference point
|
|
87
|
+
* @param tl - GSAP timeline to add animations to
|
|
88
|
+
* @param isReverse - Whether animation should play in reverse direction
|
|
89
|
+
* @param props - Configuration object with spacing, speed, delay, and other settings
|
|
21
90
|
*/
|
|
22
91
|
export declare const coreAnimation: (elementsToAnimate: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, props: GSAPReactMarqueeProps) => void;
|