File size: 2,524 Bytes
648b504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// script.js

// πŸŒ™πŸ”† Dark/Light Mode Toggle Functionality
const darkModeToggle = document.getElementById('darkModeToggle');
const body = document.body;

darkModeToggle.addEventListener('click', () => {
    body.classList.toggle('light-mode');
    darkModeToggle.textContent = body.classList.contains('light-mode') ? 'πŸŒ™' : 'πŸ”†';
});

// ✨ Custom Cursor Functionality
const cursor = document.querySelector('.custom-cursor');
const bodyElement = document.body;

bodyElement.addEventListener('mousemove', e => {
    cursor.style.transform = `translate3d(${e.clientX}px, ${e.clientY}px, 0)`;
});

bodyElement.addEventListener('mousedown', () => {
    cursor.classList.add('cursor-click');
    const clickEffect = document.createElement('div');
    clickEffect.classList.add('click-effect');
    clickEffect.style.left = `${event.clientX}px`;
    clickEffect.style.top = `${event.clientY}px`;
    document.body.appendChild(clickEffect);
    setTimeout(() => {
        clickEffect.remove();
    }, 500);
});

bodyElement.addEventListener('mouseup', () => {
    cursor.classList.remove('cursor-click');
});

// 🦸 Hero Section Live Typing Effect
const typedTextSpan = document.querySelector(".typed-text");
const cursorSpan = document.querySelector(".cursor");

const textArray = ["GENERATIVE AI & DATA SCIENCE ENGINEER", "PROMPT ENGINEER", "AI DEVELOPER"];
const typingDelay = 100;
const erasingDelay = 50;
const newTextDelay = 2000; // Delay between current text and next text
let textArrayIndex = 0;
let charIndex = 0;

function type() {
    if (charIndex < textArray[textArrayIndex].length) {
        typedTextSpan.textContent += textArray[textArrayIndex].charAt(charIndex);
        charIndex++;
        setTimeout(type, typingDelay);
    } else {
        // Typing finished, start erasing
        setTimeout(erase, newTextDelay);
    }
}

function erase() {
    if (charIndex > 0) {
        typedTextSpan.textContent = textArray[textArrayIndex].substring(0, charIndex - 1);
        charIndex--;
        setTimeout(erase, erasingDelay);
    } else {
        // Erasing finished, move to the next text
        textArrayIndex++;
        if (textArrayIndex >= textArray.length) textArrayIndex = 0;
        setTimeout(type, typingDelay + 1100);
    }
}

document.addEventListener("DOMContentLoaded", () => {
    if (textArray.length) setTimeout(type, newTextDelay + 250);
});

// ✨ Floating Particles (Initialized in the <script> tag in HTML)