-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
143 lines (118 loc) · 4.37 KB
/
Copy pathscript.js
File metadata and controls
143 lines (118 loc) · 4.37 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// Wait for DOM to be fully loaded
document.addEventListener('DOMContentLoaded', function() {
// Initialize all animations
initTypingAnimation();
initScrollAnimations();
initSmoothScroll();
addConsoleEasterEgg();
});
// Typing Animation
function initTypingAnimation() {
const typedTextElement = document.querySelector('.typed-text');
if (!typedTextElement) return;
const texts = ['DevOps Lead', 'Cloud Architect', 'Team Leader', 'Problem Solver', 'Automation Expert'];
let textIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typeText() {
const currentText = texts[textIndex];
if (isDeleting) {
typedTextElement.textContent = currentText.substring(0, charIndex - 1);
charIndex--;
} else {
typedTextElement.textContent = currentText.substring(0, charIndex + 1);
charIndex++;
}
let typeSpeed = isDeleting ? 50 : 100;
if (!isDeleting && charIndex === currentText.length) {
typeSpeed = 2000;
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
textIndex = (textIndex + 1) % texts.length;
typeSpeed = 500;
}
setTimeout(typeText, typeSpeed);
}
// Start typing animation
typeText();
}
// Scroll Animations using Intersection Observer
function initScrollAnimations() {
const sections = document.querySelectorAll('.section-animate');
if (!sections.length) return;
// Check if Intersection Observer is supported
if ('IntersectionObserver' in window) {
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver(function(entries, observer) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
// Optional: stop observing after animation
// observer.unobserve(entry.target);
}
});
}, observerOptions);
sections.forEach(function(section) {
observer.observe(section);
});
} else {
// Fallback for older browsers - just show all sections
sections.forEach(function(section) {
section.classList.add('visible');
});
}
// Also trigger on scroll for backup
window.addEventListener('scroll', handleScrollFallback);
// Initial check
handleScrollFallback();
}
function handleScrollFallback() {
const sections = document.querySelectorAll('.section-animate');
const triggerPoint = window.innerHeight * 0.85;
sections.forEach(function(section) {
const sectionTop = section.getBoundingClientRect().top;
if (sectionTop < triggerPoint) {
section.classList.add('visible');
}
});
}
// Smooth Scroll for anchor links
function initSmoothScroll() {
const anchors = document.querySelectorAll('a[href^="#"]');
anchors.forEach(function(anchor) {
anchor.addEventListener('click', function(e) {
e.preventDefault();
const targetId = this.getAttribute('href');
const target = document.querySelector(targetId);
if (target) {
target.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
});
}
// Console Easter Egg
function addConsoleEasterEgg() {
console.log('%c👋 Hey there, curious developer!', 'font-size: 20px; font-weight: bold; color: #667eea;');
console.log('%c🚀 Looking for opportunities? Reach out to me!', 'font-size: 14px; color: #764ba2;');
console.log('%c📧 shivam8770ora@gmail.com', 'font-size: 12px; color: #888;');
}
// Add hover effects for skill badges
document.addEventListener('DOMContentLoaded', function() {
const skillBadges = document.querySelectorAll('.skill-badge');
skillBadges.forEach(function(badge) {
badge.addEventListener('mouseenter', function() {
this.style.transform = 'scale(1.1) translateY(-3px)';
});
badge.addEventListener('mouseleave', function() {
this.style.transform = 'scale(1) translateY(0)';
});
});
});