Skip to content

Commit 1743b40

Browse files
committed
fix: initial morpher transition
after initial load (words[0]), start iterating list from words[1]; fixes duplication of first word after initial load
1 parent 1c3004a commit 1743b40

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/components/Morpher/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Morpher = ({
1919

2020
const morphTimeoutRef = useRef<NodeJS.Timeout | null>(null)
2121
const morphIntervalRef = useRef<NodeJS.Timeout | null>(null)
22-
const counterRef = useRef(0)
22+
const counterRef = useRef(1)
2323
const wordsRef = useRef(words)
2424
const currentTextRef = useRef(currentText)
2525
const isAnimatingRef = useRef(false)
@@ -117,10 +117,10 @@ const Morpher = ({
117117
// If reduced motion is preferred, show static text cycling
118118
if (prefersReducedMotion) {
119119
morphIntervalRef.current = setInterval(() => {
120-
counterRef.current = (counterRef.current + 1) % wordsRef.current.length
121120
const nextWord = wordsRef.current[counterRef.current]
122121
setCurrentText(nextWord)
123122
currentTextRef.current = nextWord
123+
counterRef.current = (counterRef.current + 1) % wordsRef.current.length
124124
}, 3000)
125125
} else {
126126
// Defer animation start by 2 seconds to improve initial page load

0 commit comments

Comments
 (0)