UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
🐛 fix: marquee infinite glitch
Dillion Vermad36f27c34d7f
diff --git a/content/components/marquee.mdx b/content/components/marquee.mdxindex 37f939eb..eef4a1f3 100644--- a/content/components/marquee.mdx+++ b/content/components/marquee.mdx@@ -43,11 +43,11 @@ module.exports = {keyframes: {marquee: {from: { transform: "translateX(0)" },- to: { transform: "translateX(calc(-50% - var(--gap)/2))" },+ to: { transform: "translateX(calc(-100% - var(--gap)))" },},"marquee-vertical": {from: { transform: "translateY(0)" },- to: { transform: "translateY(calc(-50% - var(--gap)/2))" },+ to: { transform: "translateY(calc(-100% - var(--gap)))" },},},},@@ -96,3 +96,4 @@ components/magicui/marquee.tsx| pauseOnHover | boolean | false | Whether or not to pause the marquee when the user hovers over the component. || vertical | boolean | false | Whether or not to display the marquee vertically. || children | node | | The content to display in the marquee. |+| repeat | number | 1 | The number of times to repeat the content. |diff --git a/registry/components/example/marquee-demo.tsx b/registry/components/example/marquee-demo.tsxindex 92741a07..25cd71de 100644--- a/registry/components/example/marquee-demo.tsx+++ b/registry/components/example/marquee-demo.tsx@@ -32,7 +32,14 @@ const reviews = [body: "I'm at a loss for words. This is amazing. I love it.",img: "https://avatar.vercel.sh/jenny",},+ {+ name: "James",+ username: "@james",+ body: "I'm at a loss for words. This is amazing. I love it.",+ img: "https://avatar.vercel.sh/james",+ },];+const firstRow = reviews.slice(0, reviews.length / 2);const secondRow = reviews.slice(reviews.length / 2);diff --git a/registry/components/magicui/marquee.tsx b/registry/components/magicui/marquee.tsxindex d12860f1..6f50a86b 100644--- a/registry/components/magicui/marquee.tsx+++ b/registry/components/magicui/marquee.tsx@@ -1,5 +1,4 @@import { cn } from "@/lib/utils";-import { Children, cloneElement } from "react";interface MarqueeProps {className?: string;@@ -7,6 +6,7 @@ interface MarqueeProps {pauseOnHover?: boolean;children?: React.ReactNode;vertical?: boolean;+ repeat?: number;[key: string]: any;}@@ -16,31 +16,36 @@ export default function Marquee({pauseOnHover = false,children,vertical = false,+ repeat = 4,...props}: MarqueeProps) {return (<div{...props}className={cn(- "flex h-full w-full overflow-hidden [--duration:40s] [--gap:1rem]",+ "group flex overflow-hidden p-2 [--duration:40s] [--gap:1rem] [gap:var(--gap)]",+ {+ "flex-row": !vertical,+ "flex-col": vertical,+ },className,)}>- <div- className={cn(- "flex h-max w-max transform-gpu items-stretch gap-[--gap] p-2",- {- "[animation-direction:reverse]": reverse,- "hover:[animation-play-state:paused]": pauseOnHover,- "animate-marquee-vertical flex-col": vertical,- "animate-marquee flex-row": !vertical,- },- )}- >- {Children.map(children, (child) => cloneElement(child as any))}- {Children.map(children, (child) => cloneElement(child as any))}- {Children.map(children, (child) => cloneElement(child as any))}- </div>+ {Array(repeat)+ .fill(0)+ .map((_, i) => (+ <div+ key={i}+ className={cn("flex shrink-0 justify-around [gap:var(--gap)]", {+ "animate-marquee flex-row": !vertical,+ "animate-marquee-vertical flex-col": vertical,+ "group-hover:[animation-play-state:paused]": pauseOnHover,+ "[animation-direction:reverse]": reverse,+ })}+ >+ {children}+ </div>+ ))}</div>);}diff --git a/tailwind.config.ts b/tailwind.config.tsindex 0c7dbca0..850262f6 100644--- a/tailwind.config.ts+++ b/tailwind.config.ts@@ -65,7 +65,7 @@ module.exports = {gradient: "gradient 8s linear infinite",meteor: "meteor 5s linear infinite",grid: "grid 15s linear infinite",- marquee: "marquee var(--duration) linear infinite",+ marquee: "marquee var(--duration) infinite linear","marquee-vertical": "marquee-vertical var(--duration) linear infinite",flip: "flip calc(var(--spark) * 2) infinite steps(2, end)",rotate: "rotate var(--spark) linear infinite both",@@ -104,11 +104,11 @@ module.exports = {},marquee: {from: { transform: "translateX(0)" },- to: { transform: "translateX(calc(-50% - var(--gap)/2))" },+ to: { transform: "translateX(calc(-100% - var(--gap)))" },},"marquee-vertical": {from: { transform: "translateY(0)" },- to: { transform: "translateY(calc(-50% - var(--gap)/2))" },+ to: { transform: "translateY(calc(-100% - var(--gap)))" },},flip: {to: { rotate: "360deg" },