@widelab-nc/widehue 1.0.40 → 1.0.41
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 +33 -128
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -24,32 +24,12 @@ 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
|
|
28
27
|
function refreshScrollTriggersAfterLoad() {
|
|
29
28
|
window.addEventListener('load', () => {
|
|
30
29
|
console.log('[ScrollTrigger] Page fully loaded — refreshing all triggers');
|
|
31
|
-
|
|
32
|
-
// ZWIĘKSZ DELAY dla Safari
|
|
33
30
|
setTimeout(() => {
|
|
34
31
|
ScrollTrigger.refresh();
|
|
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
|
-
}
|
|
32
|
+
}, 100); // bufor na przypadkowe opóźnienia, możesz zwiększyć
|
|
53
33
|
});
|
|
54
34
|
}
|
|
55
35
|
|
|
@@ -109,30 +89,12 @@ const lenis = new Lenis({
|
|
|
109
89
|
duration: 1.2,
|
|
110
90
|
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
|
|
111
91
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// 2. POPRAWKA DLA LENIS + Safari
|
|
115
92
|
function lenisScroll() {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
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
|
-
|
|
93
|
+
lenis.on('scroll', ScrollTrigger.update);
|
|
94
|
+
gsap.ticker.add((time)=>{
|
|
95
|
+
lenis.raf(time * 1000)
|
|
96
|
+
})
|
|
97
|
+
gsap.ticker.lagSmoothing(0)
|
|
136
98
|
function raf(time) {
|
|
137
99
|
lenis.raf(time);
|
|
138
100
|
requestAnimationFrame(raf);
|
|
@@ -140,8 +102,6 @@ function lenisScroll() {
|
|
|
140
102
|
requestAnimationFrame(raf);
|
|
141
103
|
}
|
|
142
104
|
|
|
143
|
-
|
|
144
|
-
|
|
145
105
|
// Lazy load videos
|
|
146
106
|
function lazyLoadVideos() {
|
|
147
107
|
let lazyVideos = [].slice.call(document.querySelectorAll("video.lazyload"));
|
|
@@ -242,10 +202,10 @@ function initBasicAnimations() {
|
|
|
242
202
|
}
|
|
243
203
|
}
|
|
244
204
|
|
|
245
|
-
// 5. ULEPSZONE pageLoadAnimation
|
|
246
205
|
function pageLoadAnimation() {
|
|
247
206
|
console.log('pageLoadAnimation function called');
|
|
248
207
|
|
|
208
|
+
// Check if all required loader elements exist
|
|
249
209
|
const requiredElements = [
|
|
250
210
|
'.loader_ract.is-left',
|
|
251
211
|
'.loader_ract.is-right',
|
|
@@ -268,20 +228,10 @@ function pageLoadAnimation() {
|
|
|
268
228
|
console.log('First animation step triggered: scrollRestoration and scrollTo');
|
|
269
229
|
history.scrollRestoration = 'manual';
|
|
270
230
|
|
|
271
|
-
//
|
|
272
|
-
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
|
|
273
|
-
|
|
231
|
+
// Safari-safe scroll to top
|
|
274
232
|
if (typeof lenis !== 'undefined' && lenis.scrollTo) {
|
|
275
233
|
try {
|
|
276
234
|
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
235
|
} catch (e) {
|
|
286
236
|
console.warn('Lenis scrollTo failed, using fallback:', e);
|
|
287
237
|
window.scrollTo(0, 0);
|
|
@@ -313,11 +263,6 @@ function pageLoadAnimation() {
|
|
|
313
263
|
console.log('lenis started');
|
|
314
264
|
if (typeof lenis !== 'undefined' && lenis.start) {
|
|
315
265
|
lenis.start();
|
|
316
|
-
|
|
317
|
-
// Refresh ScrollTrigger po starcie lenis
|
|
318
|
-
setTimeout(() => {
|
|
319
|
-
ScrollTrigger.refresh();
|
|
320
|
-
}, 100);
|
|
321
266
|
}
|
|
322
267
|
}, '>')
|
|
323
268
|
.to('.loader_wrapper', {
|
|
@@ -330,17 +275,21 @@ function pageLoadAnimation() {
|
|
|
330
275
|
|
|
331
276
|
console.log('Animation timeline defined');
|
|
332
277
|
|
|
278
|
+
// Update on screen resize - with element existence check
|
|
333
279
|
window.addEventListener('resize', function () {
|
|
334
280
|
console.log('Window resize event triggered');
|
|
335
281
|
setTimeout(function () {
|
|
336
282
|
if (document.querySelector('.loader_wrapper')) {
|
|
337
283
|
console.log('Set .loader_wrapper to display:none on resize');
|
|
338
284
|
gsap.set('.loader_wrapper', { display: 'none' });
|
|
285
|
+
} else {
|
|
286
|
+
console.warn('Loader wrapper not found on resize');
|
|
339
287
|
}
|
|
340
288
|
}, 50);
|
|
341
289
|
});
|
|
342
|
-
}
|
|
343
290
|
|
|
291
|
+
console.log('Resize event listener added');
|
|
292
|
+
}
|
|
344
293
|
|
|
345
294
|
|
|
346
295
|
// Page transition animation
|
|
@@ -551,60 +500,37 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
551
500
|
console.log('Page reloaded; session flag cleared.');
|
|
552
501
|
}
|
|
553
502
|
|
|
554
|
-
// POPRAWKA: Ustaw initial state przed SplitText
|
|
555
503
|
gsap.set('.wideletter', { y: '-150%', scale: 1 });
|
|
556
|
-
gsap.set('#heroHeading', { opacity: 0 }); // DODANE
|
|
557
504
|
|
|
558
|
-
// POPRAWKA: Scroll to top z większym delay dla Safari
|
|
559
505
|
if (typeof lenis !== 'undefined') {
|
|
560
506
|
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
|
-
|
|
565
507
|
setTimeout(() => {
|
|
566
508
|
lenis.scrollTo(0, { duration: 0, easing: (t) => t });
|
|
567
509
|
console.log('Lenis scrollTo action called after delay');
|
|
568
|
-
},
|
|
510
|
+
}, 100);
|
|
511
|
+
} else {
|
|
512
|
+
console.log('Lenis instance not found');
|
|
569
513
|
}
|
|
570
514
|
|
|
571
515
|
const videoMask = e.querySelector('.hero_headline_ract-mask');
|
|
572
516
|
const video = e.querySelector('video.lazyload');
|
|
573
517
|
const heroAnimation = gsap.timeline({});
|
|
518
|
+
const homeHeroHeading = new SplitText('#heroHeading', {
|
|
519
|
+
type: 'lines',
|
|
520
|
+
linesClass: 'hero-line',
|
|
521
|
+
});
|
|
522
|
+
const homeHeroHeadingMask = new SplitText('#heroHeading', {
|
|
523
|
+
type: 'lines',
|
|
524
|
+
linesClass: 'hero-line-mask',
|
|
525
|
+
});
|
|
574
526
|
|
|
575
|
-
|
|
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
|
-
|
|
527
|
+
const heroLines = document.querySelectorAll('.hero-line');
|
|
602
528
|
if (heroLines.length === 0) {
|
|
603
529
|
console.error('GSAP target .hero-line not found.');
|
|
604
530
|
return;
|
|
605
531
|
}
|
|
606
532
|
|
|
607
|
-
//
|
|
533
|
+
// Handle video source replacement based on viewport width
|
|
608
534
|
function updateVideoSources() {
|
|
609
535
|
const isMobile = window.innerWidth < 992;
|
|
610
536
|
const mobileMp4 = video.getAttribute('mobile-mp4');
|
|
@@ -620,19 +546,24 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
620
546
|
webmSource.setAttribute('data-src', mobileWebm);
|
|
621
547
|
}
|
|
622
548
|
} else {
|
|
549
|
+
// Revert to desktop sources if necessary
|
|
623
550
|
mp4Source.setAttribute('data-src', mp4Source.getAttribute('data-src').replace('mobile-', ''));
|
|
624
551
|
webmSource.setAttribute('data-src', webmSource.getAttribute('data-src').replace('mobile-', ''));
|
|
625
552
|
}
|
|
626
553
|
}
|
|
627
554
|
|
|
555
|
+
// Initial call to update video sources
|
|
628
556
|
updateVideoSources();
|
|
557
|
+
|
|
558
|
+
// Add event listener for window resize to update video sources
|
|
629
559
|
window.addEventListener('resize', updateVideoSources);
|
|
630
560
|
|
|
631
561
|
if (video) {
|
|
562
|
+
// Prevent the video from autoplaying when lazy-loaded
|
|
632
563
|
video.setAttribute('data-no-autoplay', 'true');
|
|
633
564
|
video.addEventListener('loadeddata', () => {
|
|
634
565
|
if (video.hasAttribute('data-no-autoplay')) {
|
|
635
|
-
video.pause();
|
|
566
|
+
video.pause(); // Ensure the video is paused if it loads
|
|
636
567
|
}
|
|
637
568
|
});
|
|
638
569
|
}
|
|
@@ -646,6 +577,7 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
646
577
|
|
|
647
578
|
heroAnimation.to('.navbar_brand_lottie', {
|
|
648
579
|
duration: 1.5,
|
|
580
|
+
// Usuń progress: 1 całkowicie
|
|
649
581
|
onComplete: function() {
|
|
650
582
|
console.log('Lottie animation completed');
|
|
651
583
|
gsap.to('.navbar_brand_lottie', { opacity: 0, duration: 0.25 });
|
|
@@ -705,33 +637,6 @@ window.heroAnimationOnLoad = function(e) {
|
|
|
705
637
|
console.log('Animation timeline setup completed');
|
|
706
638
|
}
|
|
707
639
|
|
|
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
|
-
}
|
|
735
640
|
|
|
736
641
|
window.briefContact = function(e) {
|
|
737
642
|
const button = document.querySelector('.brief-button');
|