Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
103 lines (85 loc) · 3.08 KB
/
Copy pathscript.js
File metadata and controls
103 lines (85 loc) · 3.08 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class RandomTextEffect {
constructor(element, texts, options = {}) {
this.element = element;
this.texts = texts;
this.currentIndex = 0;
this.isAnimating = false;
// Options
this.interval = options.interval || 3000; // 3 seconds default
this.animationDuration = options.animationDuration || 500; // 500ms default
this.randomizeInterval = options.randomizeInterval || true;
this.init();
}
init() {
// Set initial text
this.element.textContent = this.texts[0];
this.startRotation();
}
startRotation() {
if (this.isAnimating) return;
this.isAnimating = true;
const nextIndex = (this.currentIndex + 1) % this.texts.length;
this.animateToText(this.texts[nextIndex], () => {
this.currentIndex = nextIndex;
this.isAnimating = false;
// Schedule next change
const delay = this.randomizeInterval
? this.interval + Math.random() * 1000 // Add random 0-1 second
: this.interval;
setTimeout(() => this.startRotation(), delay);
});
}
animateToText(newText, callback) {
// Fade out
this.element.style.opacity = '0';
this.element.style.transform = 'translateY(10px)';
setTimeout(() => {
// Change text
this.element.textContent = newText;
// Fade in
this.element.style.opacity = '1';
this.element.style.transform = 'translateY(0)';
// Call callback after animation
setTimeout(callback, this.animationDuration);
}, this.animationDuration / 2);
}
}
const professionalTitles = [
'Principal Software Engineer',
'Game Developer',
'Unreal Developer',
'Unity Developer',
'Mobile Developer',
'Full-Stack Developer',
'Cross-Platform Developer',
'Technical Leader',
'System Architect',
'Code Craftsman',
'Engineering Mentor'
];
// Initialize the random text effect when DOM is loaded
document.addEventListener('DOMContentLoaded', function() {
const randomTextElement = document.getElementById('randomText');
if (randomTextElement) {
new RandomTextEffect(randomTextElement, professionalTitles, {
interval: 2500,
animationDuration: 400,
randomizeInterval: true
});
}
// Add smooth scroll behavior for any internal links
const links = document.querySelectorAll('a[href^="#"]');
links.forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href').substring(1);
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
});