@widelab-nc/widehue 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -4
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/src/index.js +190 -34
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -24,12 +24,32 @@ function customGsapEasing() {
|
|
|
24
24
|
// Contact form open animation
|
|
25
25
|
let contactFormOpen;
|
|
26
26
|
|
|
27
|
+
// 1. GŁÓWNY PROBLEM: Refresh ScrollTrigger po pełnym załadowaniu
|
|
27
28
|
function refreshScrollTriggersAfterLoad() {
|
|
28
29
|
window.addEventListener('load', () => {
|
|
29
30
|
console.log('[ScrollTrigger] Page fully loaded — refreshing all triggers');
|
|
31
|
+
|
|
32
|
+
// ZWIĘKSZ DELAY dla Safari
|
|
30
33
|
setTimeout(() => {
|
|
31
34
|
ScrollTrigger.refresh();
|
|
32
|
-
|
|
35
|
+
|
|
36
|
+
// DODATKOWY refresh dla Safari
|
|
37
|
+
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
38
|
+
setTimeout(() => {
|
|
39
|
+
ScrollTrigger.refresh();
|
|
40
|
+
console.log('[Safari] Additional ScrollTrigger refresh');
|
|
41
|
+
}, 500);
|
|
42
|
+
}
|
|
43
|
+
}, 200); // Zwiększone z 100ms do 200ms
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// DODAJ refresh na resize dla Safari
|
|
47
|
+
window.addEventListener('resize', () => {
|
|
48
|
+
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
ScrollTrigger.refresh();
|
|
51
|
+
}, 100);
|
|
52
|
+
}
|
|
33
53
|
});
|
|
34
54
|
}
|
|
35
55
|
|
|
@@ -89,12 +109,30 @@ const lenis = new Lenis({
|
|
|
89
109
|
duration: 1.2,
|
|
90
110
|
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
|
91
111
|
});
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// 2. POPRAWKA DLA LENIS + Safari
|
|
92
115
|
function lenisScroll() {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
// Sprawdź czy to Safari
|
|
117
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
118
|
+
|
|
119
|
+
lenis.on('scroll', (e) => {
|
|
120
|
+
ScrollTrigger.update();
|
|
121
|
+
|
|
122
|
+
// Dodatkowe wymuszenie update dla Safari
|
|
123
|
+
if (isSafari) {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
ScrollTrigger.update();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
gsap.ticker.add((time) => {
|
|
131
|
+
lenis.raf(time * 1000);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
gsap.ticker.lagSmoothing(0);
|
|
135
|
+
|
|
98
136
|
function raf(time) {
|
|
99
137
|
lenis.raf(time);
|
|
100
138
|
requestAnimationFrame(raf);
|
|
@@ -102,6 +140,8 @@ function lenisScroll() {
|
|
|
102
140
|
requestAnimationFrame(raf);
|
|
103
141
|
}
|
|
104
142
|
|
|
143
|
+
|
|
144
|
+
|
|
105
145
|
// Lazy load videos
|
|
106
146
|
function lazyLoadVideos() {
|
|
107
147
|
let lazyVideos = [].slice.call(document.querySelectorAll("video.lazyload"));
|
|
@@ -174,8 +214,51 @@ function revealFooter() {
|
|
|
174
214
|
}
|
|
175
215
|
}
|
|
176
216
|
|
|
217
|
+
|
|
218
|
+
// Check if element exists in DOM
|
|
219
|
+
function checkElementExists(selector) {
|
|
220
|
+
const element = document.querySelector(selector);
|
|
221
|
+
if (!element) {
|
|
222
|
+
console.warn(`Element ${selector} not found - skipping animation`);
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Fallback function when loader elements don't exist
|
|
229
|
+
function initBasicAnimations() {
|
|
230
|
+
console.log('Initializing basic animations without loader');
|
|
231
|
+
|
|
232
|
+
if (typeof lenis !== 'undefined') {
|
|
233
|
+
try {
|
|
234
|
+
lenis.scrollTo(0, { immediate: true });
|
|
235
|
+
lenis.start();
|
|
236
|
+
} catch (e) {
|
|
237
|
+
console.warn('Lenis initialization failed:', e);
|
|
238
|
+
window.scrollTo(0, 0);
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
window.scrollTo(0, 0);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// 5. ULEPSZONE pageLoadAnimation
|
|
177
246
|
function pageLoadAnimation() {
|
|
178
|
-
console.log('pageLoadAnimation function called');
|
|
247
|
+
console.log('pageLoadAnimation function called');
|
|
248
|
+
|
|
249
|
+
const requiredElements = [
|
|
250
|
+
'.loader_ract.is-left',
|
|
251
|
+
'.loader_ract.is-right',
|
|
252
|
+
'.loader_wrapper'
|
|
253
|
+
];
|
|
254
|
+
|
|
255
|
+
const allElementsExist = requiredElements.every(selector => checkElementExists(selector));
|
|
256
|
+
|
|
257
|
+
if (!allElementsExist) {
|
|
258
|
+
console.warn('Loader elements not found - skipping loader animation');
|
|
259
|
+
initBasicAnimations();
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
179
262
|
|
|
180
263
|
const loaderAnimationIn = gsap.timeline({});
|
|
181
264
|
console.log('GSAP timeline created');
|
|
@@ -184,7 +267,28 @@ function pageLoadAnimation() {
|
|
|
184
267
|
.add(function() {
|
|
185
268
|
console.log('First animation step triggered: scrollRestoration and scrollTo');
|
|
186
269
|
history.scrollRestoration = 'manual';
|
|
187
|
-
|
|
270
|
+
|
|
271
|
+
// POPRAWKA: Lepszy scroll to top dla Safari
|
|
272
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
273
|
+
|
|
274
|
+
if (typeof lenis !== 'undefined' && lenis.scrollTo) {
|
|
275
|
+
try {
|
|
276
|
+
lenis.scrollTo(0, { immediate: true });
|
|
277
|
+
|
|
278
|
+
// Dodatkowe wymuszenie dla Safari
|
|
279
|
+
if (isSafari) {
|
|
280
|
+
setTimeout(() => {
|
|
281
|
+
window.scrollTo(0, 0);
|
|
282
|
+
lenis.scrollTo(0, { immediate: true });
|
|
283
|
+
}, 50);
|
|
284
|
+
}
|
|
285
|
+
} catch (e) {
|
|
286
|
+
console.warn('Lenis scrollTo failed, using fallback:', e);
|
|
287
|
+
window.scrollTo(0, 0);
|
|
288
|
+
}
|
|
289
|
+
} else {
|
|
290
|
+
window.scrollTo(0, 0);
|
|
291
|
+
}
|
|
188
292
|
})
|
|
189
293
|
.to(
|
|
190
294
|
'.loader_ract.is-left',
|
|
@@ -207,7 +311,14 @@ function pageLoadAnimation() {
|
|
|
207
311
|
)
|
|
208
312
|
.add(function() {
|
|
209
313
|
console.log('lenis started');
|
|
210
|
-
lenis.start
|
|
314
|
+
if (typeof lenis !== 'undefined' && lenis.start) {
|
|
315
|
+
lenis.start();
|
|
316
|
+
|
|
317
|
+
// Refresh ScrollTrigger po starcie lenis
|
|
318
|
+
setTimeout(() => {
|
|
319
|
+
ScrollTrigger.refresh();
|
|
320
|
+
}, 100);
|
|
321
|
+
}
|
|
211
322
|
}, '>')
|
|
212
323
|
.to('.loader_wrapper', {
|
|
213
324
|
display: 'none',
|
|
@@ -219,18 +330,19 @@ function pageLoadAnimation() {
|
|
|
219
330
|
|
|
220
331
|
console.log('Animation timeline defined');
|
|
221
332
|
|
|
222
|
-
// Update on screen resize
|
|
223
333
|
window.addEventListener('resize', function () {
|
|
224
334
|
console.log('Window resize event triggered');
|
|
225
335
|
setTimeout(function () {
|
|
226
|
-
|
|
227
|
-
|
|
336
|
+
if (document.querySelector('.loader_wrapper')) {
|
|
337
|
+
console.log('Set .loader_wrapper to display:none on resize');
|
|
338
|
+
gsap.set('.loader_wrapper', { display: 'none' });
|
|
339
|
+
}
|
|
228
340
|
}, 50);
|
|
229
341
|
});
|
|
230
|
-
|
|
231
|
-
console.log('Resize event listener added');
|
|
232
342
|
}
|
|
233
343
|
|
|
344
|
+
|
|
345
|
+
|
|
234
346
|
// Page transition animation
|
|
235
347
|
function pageTransitionAnimation() {
|
|
236
348
|
const transitionLinks = document.querySelectorAll(
|
|
@@ -439,37 +551,60 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
439
551
|
console.log('Page reloaded; session flag cleared.');
|
|
440
552
|
}
|
|
441
553
|
|
|
554
|
+
// POPRAWKA: Ustaw initial state przed SplitText
|
|
442
555
|
gsap.set('.wideletter', { y: '-150%', scale: 1 });
|
|
556
|
+
gsap.set('#heroHeading', { opacity: 0 }); // DODANE
|
|
443
557
|
|
|
558
|
+
// POPRAWKA: Scroll to top z większym delay dla Safari
|
|
444
559
|
if (typeof lenis !== 'undefined') {
|
|
445
560
|
console.log('Lenis instance found, attempting to scroll to top');
|
|
561
|
+
|
|
562
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
563
|
+
const delay = isSafari ? 300 : 100; // Większy delay dla Safari
|
|
564
|
+
|
|
446
565
|
setTimeout(() => {
|
|
447
566
|
lenis.scrollTo(0, { duration: 0, easing: (t) => t });
|
|
448
567
|
console.log('Lenis scrollTo action called after delay');
|
|
449
|
-
},
|
|
450
|
-
} else {
|
|
451
|
-
console.log('Lenis instance not found');
|
|
568
|
+
}, delay);
|
|
452
569
|
}
|
|
453
570
|
|
|
454
571
|
const videoMask = e.querySelector('.hero_headline_ract-mask');
|
|
455
572
|
const video = e.querySelector('video.lazyload');
|
|
456
573
|
const heroAnimation = gsap.timeline({});
|
|
457
|
-
const homeHeroHeading = new SplitText('#heroHeading', {
|
|
458
|
-
type: 'lines',
|
|
459
|
-
linesClass: 'hero-line',
|
|
460
|
-
});
|
|
461
|
-
const homeHeroHeadingMask = new SplitText('#heroHeading', {
|
|
462
|
-
type: 'lines',
|
|
463
|
-
linesClass: 'hero-line-mask',
|
|
464
|
-
});
|
|
465
574
|
|
|
466
|
-
|
|
575
|
+
// POPRAWKA: Dodaj fallback jeśli SplitText nie działa
|
|
576
|
+
let homeHeroHeading, homeHeroHeadingMask, heroLines;
|
|
577
|
+
|
|
578
|
+
try {
|
|
579
|
+
homeHeroHeading = new SplitText('#heroHeading', {
|
|
580
|
+
type: 'lines',
|
|
581
|
+
linesClass: 'hero-line',
|
|
582
|
+
});
|
|
583
|
+
homeHeroHeadingMask = new SplitText('#heroHeading', {
|
|
584
|
+
type: 'lines',
|
|
585
|
+
linesClass: 'hero-line-mask',
|
|
586
|
+
});
|
|
587
|
+
|
|
588
|
+
heroLines = document.querySelectorAll('.hero-line');
|
|
589
|
+
|
|
590
|
+
if (heroLines.length === 0) {
|
|
591
|
+
throw new Error('SplitText failed to create lines');
|
|
592
|
+
}
|
|
593
|
+
} catch (error) {
|
|
594
|
+
console.error('SplitText error:', error);
|
|
595
|
+
// Fallback: użyj oryginalnego elementu
|
|
596
|
+
heroLines = [document.querySelector('#heroHeading')];
|
|
597
|
+
if (heroLines[0]) {
|
|
598
|
+
heroLines[0].classList.add('hero-line');
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
|
|
467
602
|
if (heroLines.length === 0) {
|
|
468
603
|
console.error('GSAP target .hero-line not found.');
|
|
469
604
|
return;
|
|
470
605
|
}
|
|
471
606
|
|
|
472
|
-
//
|
|
607
|
+
// Reszta funkcji bez zmian...
|
|
473
608
|
function updateVideoSources() {
|
|
474
609
|
const isMobile = window.innerWidth < 992;
|
|
475
610
|
const mobileMp4 = video.getAttribute('mobile-mp4');
|
|
@@ -485,24 +620,19 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
485
620
|
webmSource.setAttribute('data-src', mobileWebm);
|
|
486
621
|
}
|
|
487
622
|
} else {
|
|
488
|
-
// Revert to desktop sources if necessary
|
|
489
623
|
mp4Source.setAttribute('data-src', mp4Source.getAttribute('data-src').replace('mobile-', ''));
|
|
490
624
|
webmSource.setAttribute('data-src', webmSource.getAttribute('data-src').replace('mobile-', ''));
|
|
491
625
|
}
|
|
492
626
|
}
|
|
493
627
|
|
|
494
|
-
// Initial call to update video sources
|
|
495
628
|
updateVideoSources();
|
|
496
|
-
|
|
497
|
-
// Add event listener for window resize to update video sources
|
|
498
629
|
window.addEventListener('resize', updateVideoSources);
|
|
499
630
|
|
|
500
631
|
if (video) {
|
|
501
|
-
// Prevent the video from autoplaying when lazy-loaded
|
|
502
632
|
video.setAttribute('data-no-autoplay', 'true');
|
|
503
633
|
video.addEventListener('loadeddata', () => {
|
|
504
634
|
if (video.hasAttribute('data-no-autoplay')) {
|
|
505
|
-
video.pause();
|
|
635
|
+
video.pause();
|
|
506
636
|
}
|
|
507
637
|
});
|
|
508
638
|
}
|
|
@@ -516,7 +646,6 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
516
646
|
|
|
517
647
|
heroAnimation.to('.navbar_brand_lottie', {
|
|
518
648
|
duration: 1.5,
|
|
519
|
-
progress: 1,
|
|
520
649
|
onComplete: function() {
|
|
521
650
|
console.log('Lottie animation completed');
|
|
522
651
|
gsap.to('.navbar_brand_lottie', { opacity: 0, duration: 0.25 });
|
|
@@ -576,6 +705,33 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
576
705
|
console.log('Animation timeline setup completed');
|
|
577
706
|
}
|
|
578
707
|
|
|
708
|
+
// 4. DODAJ GLOBAL FIX dla Safari
|
|
709
|
+
function initSafariFixes() {
|
|
710
|
+
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
711
|
+
|
|
712
|
+
if (isSafari) {
|
|
713
|
+
console.log('Safari detected - applying fixes');
|
|
714
|
+
|
|
715
|
+
// Fix dla viewport height na mobile Safari
|
|
716
|
+
const fixViewportHeight = () => {
|
|
717
|
+
const vh = window.innerHeight * 0.01;
|
|
718
|
+
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
fixViewportHeight();
|
|
722
|
+
window.addEventListener('resize', fixViewportHeight);
|
|
723
|
+
window.addEventListener('orientationchange', () => {
|
|
724
|
+
setTimeout(fixViewportHeight, 100);
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
// Dodatkowy refresh ScrollTrigger po orientationchange
|
|
728
|
+
window.addEventListener('orientationchange', () => {
|
|
729
|
+
setTimeout(() => {
|
|
730
|
+
ScrollTrigger.refresh();
|
|
731
|
+
}, 300);
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
}
|
|
579
735
|
|
|
580
736
|
window.briefContact = function(e) {
|
|
581
737
|
const button = document.querySelector('.brief-button');
|