gsap-react-marquee 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 David Domenico Piscopo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # GSAP React Marquee
2
+
3
+ A high-performance, customizable React marquee component powered by GSAP animations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install gsap-react-marquee
9
+ # or
10
+ yarn add gsap-react-marquee
11
+ # or
12
+ pnpm add gsap-react-marquee
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```tsx
18
+ import Marquee from "gsap-react-marquee";
19
+
20
+ function App() {
21
+ return (
22
+ <Marquee dir="right" speed={100} fill={true} spacing={16}>
23
+ <div>Hello world</div>
24
+ </Marquee>
25
+ );
26
+ }
27
+ ```
28
+
29
+ ## Props
30
+
31
+ | Prop | Type | Default | Description |
32
+ | -------------------- | ------------------------------------- | --------- | --------------------------------------------------------------------------------------- |
33
+ | `children` | `ReactNode` | – | Content to render inside the marquee |
34
+ | `className` | `string` | – | Additional CSS classes for styling |
35
+ | `dir` | `"right" \| "left" \| "up" \| "down"` | `"right"` | Direction of the marquee movement |
36
+ | `loop` | `number` | `-1` | Number of loops (`-1` = infinite) |
37
+ | `paused` | `boolean` | `false` | Whether the marquee animation should be paused |
38
+ | `alignRotationWithY` | `boolean` | `false` | Correctly orients (rotates) the content along Y axis (⚠️ avoid with `"left"`/`"right"`) |
39
+ | `delay` | `number` | `0` | Delay before the animation starts |
40
+ | `speed` | `number` | `100` | Speed of the marquee animation in px/s |
41
+ | `fill` | `boolean` | `false` | Whether the marquee should continuously fill the space |
42
+ | `pauseOnHover` | `boolean` | `false` | Pause the marquee when hovering |
43
+ | `gradient` | `boolean` | `false` | Enable gradient overlay |
44
+ | `gradientColor` | `string` | – | Color of the gradient if enabled |
45
+ | `spacing` | `number` | `16` | Spacing between repeated elements in px |
46
+ | `draggable` | `boolean` | `false` | Enable dragging to scroll manually |
47
+ | `followScrollDir` | `boolean` | `false` | Sync marquee with page scroll direction |
48
+ | `scrollSpeed` | `number` | – | Speed factor when syncing with page scroll |
@@ -0,0 +1,4 @@
1
+ import "./gsap-react-marquee.style.css";
2
+ import type { GSAPReactMarqueeProps } from "./gsap-react-marquee.type";
3
+ declare const GSAPReactMarquee: import("react").ForwardRefExoticComponent<GSAPReactMarqueeProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default GSAPReactMarquee;
@@ -0,0 +1,91 @@
1
+ import type { ReactNode } from "react";
2
+ export type GSAPReactMarqueeProps = {
3
+ /** Content to render inside the marquee */
4
+ children: ReactNode;
5
+ /** Additional CSS classes for styling */
6
+ className?: string;
7
+ /**
8
+ * @description Direction of the marquee movement
9
+ * @type {"right" | "left" | "up" | "down"}
10
+ * @default "right"
11
+ */
12
+ dir?: "right" | "left" | "up" | "down";
13
+ /**
14
+ * @description The number of times the marquee should loop, -1 is equivalent to infinite
15
+ * @type {number}
16
+ * @default -1
17
+ */
18
+ loop?: number;
19
+ /**
20
+ * @description Whether the marquee animation should be paused
21
+ * @type {boolean}
22
+ * @default false
23
+ */
24
+ paused?: boolean;
25
+ /**
26
+ * @description Correctly orients (rotates) the content with respect to the Y axis.
27
+ * Useful for vertical movement ("up" | "down") to keep items upright via rotation fix.
28
+ * @issue ⚠️ Not recommended to use together with "left" or "right" direction, as it may cause layout issues.
29
+ * @type {boolean}
30
+ * @default false
31
+ */
32
+ alignRotationWithY?: boolean;
33
+ /**
34
+ * @description Delay before the animation starts
35
+ * @type {number}
36
+ * @default 0
37
+ */
38
+ delay?: number;
39
+ /**
40
+ * @description Speed of the marquee animation in px/s
41
+ * @type {number}
42
+ * @default 100
43
+ */
44
+ speed?: number;
45
+ /**
46
+ * @description Whether the marquee should continuously fill the space
47
+ * @type {boolean}
48
+ * @default false
49
+ */
50
+ fill?: boolean;
51
+ /**
52
+ * @description Pause the marquee when hovering
53
+ * @type {boolean}
54
+ * @default false
55
+ */
56
+ pauseOnHover?: boolean;
57
+ /**
58
+ * @description Enable gradient overlay
59
+ * @type {boolean}
60
+ * @default false
61
+ */
62
+ gradient?: boolean;
63
+ /**
64
+ * @description Color of the gradient if enabled
65
+ * @type {string}
66
+ */
67
+ gradientColor?: string;
68
+ /**
69
+ * @description Spacing between repeated elements in px
70
+ * @type {number}
71
+ * @default 16
72
+ */
73
+ spacing?: number;
74
+ /**
75
+ * @description Enable dragging to scroll manually
76
+ * @type {boolean}
77
+ * @default false
78
+ */
79
+ draggable?: boolean;
80
+ /**
81
+ * @description Whether to sync with page scroll direction
82
+ * @type {boolean}
83
+ * @default false
84
+ */
85
+ followScrollDir?: boolean;
86
+ /**
87
+ * @description Speed factor when syncing with page scroll
88
+ * @type {number}
89
+ */
90
+ scrollSpeed?: number;
91
+ };
@@ -0,0 +1,26 @@
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
+ export declare const cn: (...inputs: ClassValue[]) => string;
7
+ /**
8
+ * Sets up container styles and rotation handling
9
+ */
10
+ export declare const setupContainerStyles: (containerMarquee: HTMLElement, marquees: HTMLElement[], marqueesChildren: HTMLElement[], isVertical: boolean, props: GSAPReactMarqueeProps) => void;
11
+ /**
12
+ * Calculates the number of duplicates needed to fill the container
13
+ */
14
+ export declare const calculateDuplicates: (marqueeChildrenWidth: number, containerMarqueeWidth: number, isVertical: boolean, props: GSAPReactMarqueeProps) => number;
15
+ /**
16
+ * Determines the minimum width for marquee elements
17
+ */
18
+ export declare const getMinWidth: (marqueesChildren: HTMLElement[], totalWidth: number, containerMarqueeWidth: number, props: GSAPReactMarqueeProps) => string | number;
19
+ /**
20
+ * Creates a simple infinite marquee animation
21
+ */
22
+ export declare const simpleAnimation: (marquees: HTMLElement[], marqueeChildrenDimension: number, isReverse: boolean, props: GSAPReactMarqueeProps) => void;
23
+ /**
24
+ * Creates a complex fill-based marquee animation with seamless looping
25
+ */
26
+ export declare const fillAnimation: (marqueesChildren: HTMLElement[], startX: number, tl: gsap.core.Timeline, isReverse: boolean, props: GSAPReactMarqueeProps) => void;
@@ -0,0 +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}