Skip to content

Commit 26fa6d3

Browse files
committed
marquee changes
1 parent 75a68b7 commit 26fa6d3

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

src/components/DocsLayout.tsx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,32 +33,38 @@ function MobilePartnersStrip({
3333
}) {
3434
const innerRef = React.useRef<HTMLDivElement>(null)
3535
const [isHovered, setIsHovered] = React.useState(false)
36+
const scrollPositionRef = React.useRef(0)
37+
const hasStartedRef = React.useRef(false)
3638

3739
React.useEffect(() => {
3840
const inner = innerRef.current
3941
if (!inner) return
4042

4143
let animationId: number
4244
let timeoutId: ReturnType<typeof setTimeout>
43-
let scrollPosition = 0
44-
const scrollSpeed = 0.08 // pixels per frame - very slow
45-
const startDelay = 4000 // wait 4 seconds before starting
45+
const scrollSpeed = 0.15 // pixels per frame
46+
const startDelay = 4000 // wait 4 seconds before starting (first time only)
4647

4748
const animate = () => {
4849
if (!isHovered && inner) {
49-
scrollPosition += scrollSpeed
50+
scrollPositionRef.current += scrollSpeed
5051
// Reset when we've scrolled past the first set
51-
if (scrollPosition >= inner.scrollWidth / 2) {
52-
scrollPosition = 0
52+
if (scrollPositionRef.current >= inner.scrollWidth / 2) {
53+
scrollPositionRef.current = 0
5354
}
54-
inner.style.transform = `translateX(${-scrollPosition}px)`
55+
inner.style.transform = `translateX(${-scrollPositionRef.current}px)`
5556
}
5657
animationId = requestAnimationFrame(animate)
5758
}
5859

59-
timeoutId = setTimeout(() => {
60+
if (!hasStartedRef.current) {
61+
timeoutId = setTimeout(() => {
62+
hasStartedRef.current = true
63+
animationId = requestAnimationFrame(animate)
64+
}, startDelay)
65+
} else {
6066
animationId = requestAnimationFrame(animate)
61-
}, startDelay)
67+
}
6268

6369
return () => {
6470
clearTimeout(timeoutId)

src/components/TrustedByMarquee.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,23 @@ type TrustedByMarqueeProps = {
2525

2626
export function TrustedByMarquee({
2727
brands,
28-
speed = 40,
28+
speed = 150,
2929
className,
3030
}: TrustedByMarqueeProps) {
3131
const animationDuration = `${(brands.length * 200) / speed}s`
3232

3333
return (
34-
<div className={twMerge('overflow-hidden w-full', className)}>
34+
<div className={twMerge('overflow-hidden w-full group', className)}>
3535
<div className="uppercase tracking-wider text-sm font-semibold text-center text-gray-400 mb-6">
3636
Trusted in Production by
3737
</div>
3838
<div className="relative w-full">
3939
{/* Left fade */}
40-
<div className="absolute left-0 top-0 bottom-0 w-16 bg-gradient-to-r from-white dark:from-black to-transparent z-10 pointer-events-none" />
40+
<div className="absolute left-0 top-0 bottom-0 w-16 bg-gradient-to-r from-[#fdfdfd] dark:from-[#0a0a0a] to-transparent z-10 pointer-events-none" />
4141
{/* Right fade */}
42-
<div className="absolute right-0 top-0 bottom-0 w-16 bg-gradient-to-l from-white dark:from-black to-transparent z-10 pointer-events-none" />
42+
<div className="absolute right-0 top-0 bottom-0 w-16 bg-gradient-to-l from-[#fdfdfd] dark:from-[#0a0a0a] to-transparent z-10 pointer-events-none" />
4343
<div
44-
className="flex gap-8 items-center whitespace-nowrap will-change-transform animate-[marquee_linear_infinite]"
44+
className="flex gap-8 items-center whitespace-nowrap will-change-transform animate-[marquee_linear_infinite] group-hover:[animation-play-state:paused]"
4545
style={{
4646
animationDuration,
4747
}}

0 commit comments

Comments
 (0)