-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.js
32 lines (28 loc) · 1.26 KB
/
javascript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const dynamicText = document.querySelector("h1 span");
const words = ["Your Gateway to Cinematic WondersLove", "Where Movie Magic Meets Your Screen", "Discover, Stream, Enjoy", "..."];
// Variables to track the position and deletion status of the word
let wordIndex = 0;
let charIndex = 0;
let isDeleting = false;
const typeEffect = () => {
const currentWord = words[wordIndex];
const currentChar = currentWord.substring(0, charIndex);
dynamicText.textContent = currentChar;
dynamicText.classList.add("stop-blinking");
if (!isDeleting && charIndex < currentWord.length) {
// If condition is true, type the next character
charIndex++;
setTimeout(typeEffect, 25); // Reduced timeout for faster typing
} else if (isDeleting && charIndex > 0) {
// If condition is true, remove the previous character
charIndex--;
setTimeout(typeEffect, 10); // Reduced timeout for faster deleting
} else {
// If word is deleted then switch to the next word
isDeleting = !isDeleting;
dynamicText.classList.remove("stop-blinking");
wordIndex = !isDeleting ? (wordIndex + 1) % words.length : wordIndex;
setTimeout(typeEffect, 100); // Reduced timeout for switching words
}
}
typeEffect();