-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
273 lines (235 loc) · 9.07 KB
/
Copy pathapp.js
File metadata and controls
273 lines (235 loc) · 9.07 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
document.addEventListener("DOMContentLoaded", () => {
const t = window.t
if (typeof t === "undefined") {
console.error("[v0] Translations not loaded")
return
}
// Custom Cursor
const cursor = document.getElementById("custom-cursor")
let mouseX = 0,
mouseY = 0
let cursorX = 0,
cursorY = 0
document.addEventListener("mousemove", (e) => {
mouseX = e.clientX
mouseY = e.clientY
cursor.classList.add("active")
})
function animateCursor() {
cursorX += (mouseX - cursorX) * 0.15
cursorY += (mouseY - cursorY) * 0.15
cursor.style.left = cursorX + "px"
cursor.style.top = cursorY + "px"
requestAnimationFrame(animateCursor)
}
animateCursor()
// Cursor hover effects
document.querySelectorAll("button, a").forEach((el) => {
el.addEventListener("mouseenter", () => cursor.classList.add("hover"))
el.addEventListener("mouseleave", () => cursor.classList.remove("hover"))
})
// Scroll functionality
const scrollContainer = document.getElementById("scroll-container")
let currentSection = 0
let touchStartY = 0
let touchStartX = 0
function scrollToSection(index) {
const sectionWidth = window.innerWidth
scrollContainer.scrollTo({
left: sectionWidth * index,
behavior: "smooth",
})
currentSection = index
}
// Scroll buttons
document.querySelectorAll("[data-scroll-to]").forEach((btn) => {
btn.addEventListener("click", () => {
const target = Number.parseInt(btn.getAttribute("data-scroll-to"))
scrollToSection(target)
})
})
// Touch navigation
scrollContainer.addEventListener(
"touchstart",
(e) => {
touchStartY = e.touches[0].clientY
touchStartX = e.touches[0].clientX
},
{ passive: true },
)
scrollContainer.addEventListener(
"touchend",
(e) => {
const touchEndY = e.changedTouches[0].clientY
const touchEndX = e.changedTouches[0].clientX
const deltaY = touchStartY - touchEndY
const deltaX = touchStartX - touchEndX
if (Math.abs(deltaY) > Math.abs(deltaX) && Math.abs(deltaY) > 50) {
if (deltaY > 0 && currentSection < 4) {
scrollToSection(currentSection + 1)
} else if (deltaY < 0 && currentSection > 0) {
scrollToSection(currentSection - 1)
}
}
},
{ passive: true },
)
// Wheel navigation
scrollContainer.addEventListener(
"wheel",
(e) => {
if (Math.abs(e.deltaY) > Math.abs(e.deltaX)) {
e.preventDefault()
scrollContainer.scrollBy({ left: e.deltaY, behavior: "instant" })
const sectionWidth = window.innerWidth
const newSection = Math.round(scrollContainer.scrollLeft / sectionWidth)
if (newSection !== currentSection) {
currentSection = newSection
}
}
},
{ passive: false },
)
// Scroll tracking
scrollContainer.addEventListener(
"scroll",
() => {
const sectionWidth = window.innerWidth
const newSection = Math.round(scrollContainer.scrollLeft / sectionWidth)
if (newSection !== currentSection && newSection >= 0 && newSection <= 4) {
currentSection = newSection
}
},
{ passive: true },
)
// Intersection Observer for reveal animations
const observerOptions = {
root: null,
threshold: 0.3,
rootMargin: "0px",
}
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible")
}
})
}, observerOptions)
document.querySelectorAll(".reveal-left, .reveal-right, .reveal-top, .reveal-bottom").forEach((el) => {
observer.observe(el)
})
// Populate content
document.getElementById("hero-title").textContent = t.hero.title
document.getElementById("hero-description").textContent = t.hero.description
document.getElementById("cta-primary").textContent = t.hero.cta_primary
document.getElementById("scroll-hint").textContent = t.hero.scroll_hint
document.getElementById("scroll-hint-work").textContent = t.hero.scroll_hint
document.getElementById("scroll-hint-services").textContent = t.hero.scroll_hint
document.getElementById("scroll-hint-about").textContent = t.hero.scroll_hint
// Work section
document.getElementById("work-heading").textContent = t.work.heading
document.getElementById("work-subtitle").textContent = t.work.subtitle
// Skills section
const skillsGrid = document.getElementById("skills-grid")
t.work.skills.forEach((skill, i) => {
const card = document.createElement("div")
card.className = "skill-card reveal-bottom"
card.style.transitionDelay = `${i * 100}ms`
card.innerHTML = `
<div class="skill-header">
<h3 class="skill-name">${skill.name}</h3>
<span class="skill-level">${skill.level}</span>
</div>
<p class="skill-description">${skill.description}</p>
<div class="skill-accent"></div>
`
skillsGrid.appendChild(card)
observer.observe(card)
})
// Services section
document.getElementById("services-heading").textContent = t.services.heading
document.getElementById("services-subtitle").textContent = t.services.subtitle
const servicesGrid = document.getElementById("services-grid")
const directions = ["top", "right", "left", "bottom"]
t.services.items.forEach((service, i) => {
const card = document.createElement("div")
card.className = `service-card reveal-${directions[i]}`
card.style.transitionDelay = `${i * 150}ms`
card.innerHTML = `
<div class="service-header">
<div class="service-line"></div>
<span class="service-number">0${i + 1}</span>
</div>
<h3 class="service-title">${service.title}</h3>
<p class="service-description">${service.description}</p>
`
servicesGrid.appendChild(card)
observer.observe(card)
})
// About section
document.getElementById("about-heading").textContent = t.about.heading
document.getElementById("about-description1").textContent = t.about.description1
document.getElementById("about-description2").textContent = t.about.description2
const statsList = document.getElementById("stats-list")
t.about.stats.forEach((stat, i) => {
const direction = ["right", "left", "right"][i]
const item = document.createElement("div")
item.className = `stat-item reveal-${direction}`
item.style.transitionDelay = `${300 + i * 150}ms`
item.innerHTML = `
<div class="stat-value">${stat.value}</div>
<div>
<div class="stat-label">${stat.label}</div>
<div class="stat-sublabel">${stat.sublabel}</div>
</div>
`
statsList.appendChild(item)
observer.observe(item)
})
document.getElementById("about-cta-secondary").textContent = t.about.cta_secondary
// Contact section
document.getElementById("contact-heading").textContent = t.contact.heading
document.getElementById("contact-subtitle").textContent = t.contact.subtitle
document.getElementById("contact-email-label").textContent = t.contact.email_label
document.getElementById("contact-phone-label").textContent = t.contact.phone_label
document.getElementById("contact-location-label").textContent = t.contact.location_label
document.getElementById("contact-email").textContent = t.contact.email
document.getElementById("contact-phone").textContent = t.contact.phone
document.getElementById("contact-location").textContent = t.contact.location
document.getElementById("form-name-label").textContent = t.contact.form.name_label
document.getElementById("form-name").placeholder = t.contact.form.name_placeholder
document.getElementById("form-email-label").textContent = t.contact.form.email_label
document.getElementById("form-email").placeholder = t.contact.form.email_placeholder
document.getElementById("form-message-label").textContent = t.contact.form.message_label
document.getElementById("form-message").placeholder = t.contact.form.message_placeholder
document.getElementById("form-submit").textContent = t.contact.form.submit
// Form submission
document.getElementById("contact-form").addEventListener("submit", async (e) => {
e.preventDefault()
const submitBtn = document.getElementById("form-submit")
const successMsg = document.getElementById("form-success")
submitBtn.textContent = t.contact.form.submitting
submitBtn.disabled = true
await new Promise((resolve) => setTimeout(resolve, 1500))
submitBtn.textContent = t.contact.form.submit
submitBtn.disabled = false
document.getElementById("contact-form").reset()
successMsg.textContent = t.contact.form.success
successMsg.classList.add("show")
setTimeout(() => {
successMsg.classList.remove("show")
}, 5000)
})
// Button actions
document.getElementById("cta-primary").addEventListener("click", () => {
scrollToSection(4) // Navigate to contact section
})
document.getElementById("about-cta-secondary").addEventListener("click", () => {
scrollToSection(4)
})
// Load animation
setTimeout(() => {
document.querySelector(".shader-background").classList.add("loaded")
document.querySelector(".main-container").classList.add("loaded")
}, 100)
})