MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / startTypingAnimation

Function startTypingAnimation

web/src/components/IDEDemo.tsx:309–351  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

307 }
308
309 const startTypingAnimation = () => {
310 let currentPhraseIndex = 0
311 setIsTyping(true)
312
313 const typePhrase = (phrase: string, callback: () => void) => {
314 let index = 0
315
316 const typeNextChar = () => {
317 if (index < phrase.length) {
318 setTypingText(phrase.substring(0, index + 1))
319 index++
320
321 // Random typing speed between 50ms and 150ms for realistic effect
322 const typingSpeed = Math.floor(Math.random() * 100) + 50
323 setTimeout(typeNextChar, typingSpeed)
324 } else {
325 // Phrase is fully typed, wait before moving to next phrase
326 setTimeout(callback, 1500)
327 }
328 }
329
330 typeNextChar()
331 }
332
333 const startNextPhrase = () => {
334 const phrase = PHRASES_TO_TYPE[currentPhraseIndex]
335
336 // Reset text before starting new phrase
337 setTypingText('')
338
339 // Small delay before starting to type the next phrase
340 setTimeout(() => {
341 typePhrase(phrase, () => {
342 // Move to next phrase (cycle back to beginning if needed)
343 currentPhraseIndex =
344 (currentPhraseIndex + 1) % PHRASES_TO_TYPE.length
345 startNextPhrase()
346 })
347 }, 300)
348 }
349
350 startNextPhrase()
351 }
352
353 setTimeout(processNextMessage, 500)
354 }, [showIDE])

Callers 1

processNextMessageFunction · 0.85

Calls 1

startNextPhraseFunction · 0.85

Tested by

no test coverage detected