Repository navigation
Expand file tree
/
Copy pathloader.js
More file actions
156 lines (135 loc) · 3.93 KB
/
Copy pathloader.js
File metadata and controls
156 lines (135 loc) · 3.93 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
// Masterpiece Loader with Image Loading Tracking
document.addEventListener('DOMContentLoaded', function() {
document.body.style.overflow = 'hidden';
const tl = gsap.timeline();
// Sequential Reveal: V and N first, then inner letters
const letters = document.querySelectorAll('.letter');
const v = letters[0];
const n = letters[6];
const inner = Array.from(letters).slice(1, 6);
// Track all images and videos for loading
const allImages = document.querySelectorAll('img');
const allVideos = document.querySelectorAll('video');
let loadedCount = 0;
let totalCount = allImages.length + allVideos.length;
function updateProgress() {
const progressPercent = totalCount > 0 ? (loadedCount / totalCount) * 100 : 0;
const progressBar = document.getElementById('progress-bar');
if (progressBar) {
progressBar.style.width = progressPercent + '%';
}
}
function checkAllLoaded() {
return loadedCount >= totalCount;
}
// Track image loads
allImages.forEach((img) => {
if (img.complete && img.naturalHeight !== 0) {
loadedCount++;
} else {
img.addEventListener('load', () => {
loadedCount++;
updateProgress();
if (checkAllLoaded()) {
setTimeout(triggerLoaderExit, 800);
}
});
img.addEventListener('error', () => {
loadedCount++;
updateProgress();
if (checkAllLoaded()) {
setTimeout(triggerLoaderExit, 800);
}
});
}
});
// Track video loads
allVideos.forEach((video) => {
if (video.readyState >= 3) {
loadedCount++;
} else {
video.addEventListener('loadeddata', () => {
loadedCount++;
updateProgress();
if (checkAllLoaded()) {
setTimeout(triggerLoaderExit, 800);
}
});
}
});
updateProgress();
// Beautiful Animation Sequence
// Phase 1: VELTRIN brand fades in elegantly FIRST (0-2.5s)
tl.to("#logo", {
opacity: 1,
duration: 2.5,
ease: "power1.inOut"
}, 0)
// Phase 2: V and N catch the light (2.5-4s) - starts AFTER brand is visible
.to([v, n], {
opacity: 1,
y: 0,
duration: 1.2,
ease: "power2.inOut"
}, 2.5)
// Phase 3: Middle letters follow smoothly (3-5s)
.to(inner, {
opacity: 1,
y: 0,
duration: 1.2,
stagger: 0.08,
ease: "power2.inOut"
}, 3)
// Phase 4: Light sweep across text (3.5-6s)
.to("#logo", {
backgroundPositionX: "-200%",
duration: 2.5,
ease: "power1.inOut"
}, 3.5)
// Phase 5: Gold dot pulses (4-6.5s)
.to("#dot", { scale: 1.5, repeat: 2, yoyo: true, duration: 0.7, ease: "sine.inOut" }, 4);
function triggerLoaderExit() {
const closeTl = gsap.timeline();
closeTl
// Fade everything out smoothly
.to("#logo, #dot, #loading-text, .progress-container", {
opacity: 0,
filter: "blur(8px)",
duration: 0.8,
ease: "power1.inOut"
}, 0)
// Shutters slide open dramatically
.to(".shutter.left", {
xPercent: -101,
duration: 1.2,
ease: "expo.inOut"
}, 0.2)
.to(".shutter.right", {
xPercent: 101,
duration: 1.2,
ease: "expo.inOut"
}, 0.2)
// Hide loader
.set("#loader-wrapper", { display: "none" }, "-=0.5")
// Show navbar and unlock scroll
.call(() => {
document.body.style.overflow = 'auto';
const navbar = document.querySelector('.navbar');
if (navbar) navbar.style.opacity = '1';
if (navbar) navbar.style.pointerEvents = 'auto';
}, null, 0);
}
// Fallback timeout (12 seconds)
setTimeout(() => {
const loader = document.getElementById('loader-wrapper');
if (loader && loader.style.display !== 'none') {
triggerLoaderExit();
}
}, 12000);
// Ensure exit after window load
window.addEventListener('load', () => {
if (checkAllLoaded()) {
setTimeout(triggerLoaderExit, 800);
}
});
});