From 14c508786a202d91d5d9ed698ca6d6f2e23a6747 Mon Sep 17 00:00:00 2001 From: Nikolaj Frey Date: Tue, 27 Jun 2023 18:09:21 +1000 Subject: [PATCH] feat: main Updated text animation 1 --- remix/app/components/textAnimation1.tsx | 33 ++++++++++++------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/remix/app/components/textAnimation1.tsx b/remix/app/components/textAnimation1.tsx index 7f65594..82fc6d6 100644 --- a/remix/app/components/textAnimation1.tsx +++ b/remix/app/components/textAnimation1.tsx @@ -4,32 +4,31 @@ import React from 'react' export const TextAnimation1 = props => { const texts = React.useMemo(() => { return [ - // 't', + 'thingtime', + 'creative', 'tt', - 'thingtime' - // 'tt / thingtime' - // 'tht', - // 'thit', - // 'thint', - // 'thingt', - // 'thingti', - // 'thingtim', - // 'thingtime', - // 'Thingtime', - // 'ThingTime', - // 'Thing Time' + 'vibrant', + 'powerful', + 'love', + 'infinite', + 'magical', + 'inspiring' ] }, []) const [titleText, setTitleText] = React.useState(texts[0]) React.useEffect(() => { - const interval = setInterval(() => { - const newTextIdx = texts?.indexOf(titleText) + 1 + const newTimeout = Math.random() * 3500 + 1500 + + setTimeout(() => { + let newTextIdx = Math.round(Math.random() * (texts.length - 1)) + if (newTextIdx === texts.indexOf(titleText)) { + newTextIdx = newTextIdx + 1 + } const newText = texts[newTextIdx] || texts[0] setTitleText(newText) - }, 4000) - return () => clearInterval(interval) + }, newTimeout) }, [titleText, texts]) return {titleText}