gsap-react-marquee 0.2.3 → 0.2.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/LICENSE +21 -21
- package/README.md +87 -48
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.esm.js +1 -1
- package/dist/types/components/gsap-react-marquee.styles.d.ts +2 -0
- package/dist/types/components/gsap-reactmarquee.utils.d.ts +3 -1
- package/package.json +72 -72
- package/dist/components/gsap-react-marquee.d.ts +0 -4
- package/dist/components/gsap-react-marquee.type.d.ts +0 -92
- package/dist/components/gsap-reactmarquee.utils.d.ts +0 -121
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.css +0 -1
- package/dist/index.esm.js.map +0 -1
- /package/dist/{index.cjs.css → gsap-react-marquee.css} +0 -0
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { type ClassValue } from "clsx";
|
|
2
|
-
import type { GSAPReactMarqueeProps } from "./gsap-react-marquee.type";
|
|
3
|
-
/**
|
|
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
|
|
12
|
-
*/
|
|
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;
|
|
40
|
-
/**
|
|
41
|
-
* Sets up container styles and rotation handling for the marquee
|
|
42
|
-
*
|
|
43
|
-
* This function handles the complex styling requirements for different marquee orientations:
|
|
44
|
-
*
|
|
45
|
-
* 1. **Basic Setup**: Applies gap spacing and rotation for vertical marquees
|
|
46
|
-
* 2. **Vertical Mode**: Rotates container 90° and adjusts width to parent height
|
|
47
|
-
* 3. **Rotation Alignment**: Special mode for vertical text that remains readable
|
|
48
|
-
*
|
|
49
|
-
* @param containerMarquee - The main container element that holds all marquee instances
|
|
50
|
-
* @param marquees - Array of individual marquee wrapper elements
|
|
51
|
-
* @param marqueesChildren - Array of content container elements within each marquee
|
|
52
|
-
* @param isVertical - Boolean indicating if marquee moves up/down instead of left/right
|
|
53
|
-
* @param props - Configuration object containing spacing and alignment options
|
|
54
|
-
*/
|
|
55
|
-
export declare const setupContainerStyles: (containerMarquee: HTMLElement, marquees: HTMLElement[], marqueesChildren: HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
|
|
56
|
-
/**
|
|
57
|
-
* Calculates the number of content duplicates needed for seamless looping
|
|
58
|
-
*
|
|
59
|
-
* For smooth infinite scrolling, we need enough content copies to fill the visible area
|
|
60
|
-
* plus buffer space. This prevents gaps when content loops back to the beginning.
|
|
61
|
-
*
|
|
62
|
-
* Algorithm:
|
|
63
|
-
* 1. If not in fill mode, only one copy is needed (content already spans container)
|
|
64
|
-
* 2. Determine target width (viewport height for vertical, container width for horizontal)
|
|
65
|
-
* 3. Calculate how many copies fit in the target space, rounding up for complete coverage
|
|
66
|
-
*
|
|
67
|
-
* @param marqueeChildrenWidth - Width of a single content instance
|
|
68
|
-
* @param containerMarqueeWidth - Width of the marquee container
|
|
69
|
-
* @param isVertical - Whether the marquee scrolls vertically
|
|
70
|
-
* @param props - Configuration object containing fill mode setting
|
|
71
|
-
* @returns Number of content duplicates needed (minimum 1)
|
|
72
|
-
*/
|
|
73
|
-
export declare const calculateDuplicates: (marqueeChildrenWidth: number, containerMarqueeWidth: number, isVertical: boolean, props: GSAPReactMarqueeProps) => number;
|
|
74
|
-
/**
|
|
75
|
-
* Determines the minimum width for marquee elements based on content and container
|
|
76
|
-
*
|
|
77
|
-
* This function ensures marquee elements have appropriate dimensions for their content
|
|
78
|
-
* and container context, handling different modes and orientations.
|
|
79
|
-
*
|
|
80
|
-
* Width determination logic:
|
|
81
|
-
* 1. **Fill mode**: Auto width lets content size naturally
|
|
82
|
-
* 2. **Rotation alignment**: Use content height as width (rotated dimensions)
|
|
83
|
-
* 3. **Undersized content**: Stretch to 100% to fill container
|
|
84
|
-
* 4. **Oversized content**: Use actual content width for overflow scrolling
|
|
85
|
-
*
|
|
86
|
-
* @param marqueesChildren - Array of content elements for dimension measurement
|
|
87
|
-
* @param totalWidth - Combined width of all content elements
|
|
88
|
-
* @param containerMarqueeWidth - Available container width
|
|
89
|
-
* @param props - Configuration object containing fill and alignment settings
|
|
90
|
-
* @returns CSS width value (string with units or number for pixels)
|
|
91
|
-
*/
|
|
92
|
-
export declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth: number, containerMarqueeWidth: number, props: GSAPReactMarqueeProps) => string | number;
|
|
93
|
-
/**
|
|
94
|
-
* Creates a complex marquee animation with seamless looping and draggable support
|
|
95
|
-
*
|
|
96
|
-
* This is the core animation engine that creates smooth, continuous scrolling.
|
|
97
|
-
* It handles the complex math required for seamless looping by calculating
|
|
98
|
-
* precise positions and durations for each content element.
|
|
99
|
-
*
|
|
100
|
-
* Animation Strategy:
|
|
101
|
-
* 1. **Position Calculation**: Convert pixel positions to percentages for responsive scaling
|
|
102
|
-
* 2. **Seamless Looping**: Calculate track length and loop points to prevent gaps
|
|
103
|
-
* 3. **Staggered Animation**: Each element starts at different times for smooth flow
|
|
104
|
-
* 4. **Direction Handling**: Support forward and reverse directions with proper timing
|
|
105
|
-
* 5. **Integrated Draggable**: Optional support for drag interaction with manual control
|
|
106
|
-
*
|
|
107
|
-
* Technical Details:
|
|
108
|
-
* - Uses xPercent for percentage-based positioning (responsive to element width changes)
|
|
109
|
-
* - Creates two-part animation: main movement + seamless loop reset
|
|
110
|
-
* - Calculates precise durations based on distance and speed for consistent motion
|
|
111
|
-
* - Implements draggable with intelligent pause/resume animation handling
|
|
112
|
-
*
|
|
113
|
-
* @param elementsToAnimate - Array of DOM elements to animate (content or containers)
|
|
114
|
-
* @param startX - Starting X position reference point
|
|
115
|
-
* @param tl - GSAP timeline to add animations to
|
|
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
|
|
119
|
-
* @param props - Configuration object with spacing, speed, delay, and other settings
|
|
120
|
-
*/
|
|
121
|
-
export declare const coreAnimation: (elementsToAnimate: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, draggableTrigger: HTMLElement | HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
|