Repository navigation
Expand file tree
/
Copy pathapp.js
More file actions
201 lines (175 loc) · 7.1 KB
/
Copy pathapp.js
File metadata and controls
201 lines (175 loc) · 7.1 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
// Get all project videos
const projectVideos = document.querySelectorAll('.project-vidbox video');
const hoverSigns = document.querySelectorAll('.hover-sign');
// Function to detect mobile devices
function isMobileDevice() {
return /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(navigator.userAgent) ||
(window.innerWidth <= 768);
}
// Debounce function for resize events
function debounce(func, wait) {
let timeout;
return function executedFunction(...args) {
const later = () => {
clearTimeout(timeout);
func(...args);
};
clearTimeout(timeout);
timeout = setTimeout(later, wait);
};
}
// Function to setup video behavior
function setupVideoPlayback() {
// Remove existing event listeners first
projectVideos.forEach(function(video) {
video.removeEventListener("mouseover", video.playHandler);
video.removeEventListener("mouseout", video.pauseHandler);
});
if (isMobileDevice()) {
// Mobile: Auto-play all project videos continuously
projectVideos.forEach(function(video, index) {
video.autoplay = true;
video.play().catch(() => {}); // Catch any play errors
// Show hover signs on mobile
if (hoverSigns[index]) {
hoverSigns[index].classList.add("active");
}
});
} else {
// Desktop: Keep hover functionality
projectVideos.forEach(function(video, index) {
// Store handlers for later removal
video.playHandler = function() {
video.play().catch(() => {}); // Catch any play errors
if (hoverSigns[index]) {
hoverSigns[index].classList.add("active");
}
};
video.pauseHandler = function() {
video.pause();
if (hoverSigns[index]) {
hoverSigns[index].classList.remove("active");
}
};
video.addEventListener("mouseover", video.playHandler);
video.addEventListener("mouseout", video.pauseHandler);
});
}
}
// Initialize video playback
setupVideoPlayback();
// Handle window resize with debounce to improve performance
window.addEventListener('resize', debounce(setupVideoPlayback, 250));
// Sidebar elements //
const sideBar = document.querySelector('.sidebar');
const menu = document.querySelector('.menu-icon');
const closeIcon = document.querySelector('.close-icon');
const sidebarNavLinks = document.querySelectorAll('.sidebar .nav-link, .sidebar a[href="#"]');
menu.addEventListener("click", function() {
sideBar.classList.remove("close-sidebar");
sideBar.classList.add("open-sidebar");
});
closeIcon.addEventListener("click", function() {
sideBar.classList.remove("open-sidebar");
sideBar.classList.add("close-sidebar");
});
// Auto-close sidebar when navigation links are clicked
sidebarNavLinks.forEach(function(link) {
link.addEventListener("click", function() {
sideBar.classList.remove("open-sidebar");
sideBar.classList.add("close-sidebar");
});
});
// Scroll down button functionality
const scrollDownBtn = document.querySelector('.scroll-down');
if (scrollDownBtn) {
scrollDownBtn.addEventListener('click', function() {
const aboutSection = document.getElementById('about');
if (aboutSection) {
aboutSection.scrollIntoView({
behavior: 'smooth',
block: 'start'
});
}
});
}
// Boot animation - hide after animation completes and show main portfolio
window.addEventListener('DOMContentLoaded', function() {
const bootScreen = document.querySelector('.boot-screen');
const mainPortfolio = document.getElementById('main-portfolio');
// Initially hide main portfolio
if (mainPortfolio) {
mainPortfolio.style.display = 'none';
}
// After animation completes, hide boot screen and show portfolio
setTimeout(function() {
if (bootScreen) {
// Use CSS transition for smooth fade
bootScreen.style.opacity = '0';
bootScreen.style.transition = 'opacity 0.5s ease';
setTimeout(function() {
bootScreen.style.display = 'none';
// Remove from DOM to free memory
bootScreen.remove();
if (mainPortfolio) {
mainPortfolio.style.display = 'block';
}
}, 500);
}
}, 5500); // 5.5 seconds - right after PORTFOLIO disappears
});
// Social box logic
document.addEventListener('DOMContentLoaded', function() {
// Contact form logic
const form = document.getElementById('contactForm');
if (form) {
const sendBtn = document.getElementById('sendBtn');
const inputs = Array.from(form.querySelectorAll('input'));
function checkInputs() {
const allFilled = inputs.every(input => input.value.trim() !== '');
sendBtn.disabled = !allFilled;
}
checkInputs();
inputs.forEach(input => input.addEventListener('input', checkInputs));
form.addEventListener('submit', function(e) {
e.preventDefault();
const name = document.getElementById('fullName').value.trim();
const email = document.getElementById('email').value.trim();
const message = document.getElementById('message').value.trim();
const subject = `Contact from ${name}`;
const body = `Name: ${name}\nEmail: ${email}\nMessage: ${message}`;
const mailto = `mailto:morandinilouis@gmail.com?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
window.location.href = mailto;
});
}
// Social box logic
// Select the social-box container
const socialBox = document.querySelector('.social-box');
if (socialBox) {
// Phone link
const phoneLink = socialBox.querySelector("a i.bxs-phone")?.parentElement;
if (phoneLink) {
phoneLink.addEventListener('click', function(e) {
const isMobile = /Android|iPhone|iPad|iPod|Opera Mini|IEMobile|WPDesktop/i.test(navigator.userAgent);
if (isMobile) {
window.location.href = 'tel:+819025201603';
} else {
alert('This function is only available on mobile devices.');
}
e.preventDefault();
});
}
// GitHub link
const githubLink = socialBox.querySelector("a i.bxl-github")?.parentElement;
if (githubLink) {
githubLink.setAttribute('href', 'https://github.com/Yukikaze-coder');
githubLink.setAttribute('target', '_blank');
}
// LinkedIn link
const linkedinLink = socialBox.querySelector("a i.bxl-linkedin-square")?.parentElement;
if (linkedinLink) {
linkedinLink.setAttribute('href', 'https://www.linkedin.com/in/luigi-morandini-22307b34b');
linkedinLink.setAttribute('target', '_blank');
}
}
});