@widelab-nc/widelab 1.0.1 → 1.0.2

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/src/index.js CHANGED
@@ -1,13 +1,975 @@
1
1
  import {initAlpine} from "./init";
2
+ import Lenis from '@studio-freight/lenis';
3
+ import { gsap } from 'gsap';
4
+ import { CustomEase } from 'gsap/CustomEase';
5
+ import { ScrollToPlugin } from 'gsap/ScrollToPlugin';
6
+ import { ScrollTrigger } from 'gsap/ScrollTrigger';
7
+ import { SplitText } from 'gsap/SplitText';
8
+ import lozad from 'lozad';
9
+ import Splide from '@splidejs/splide';
10
+ import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin';
11
+
12
+ // Register GSAP plugins
13
+ gsap.registerPlugin(DrawSVGPlugin, ScrollTrigger, SplitText, CustomEase, ScrollToPlugin);
14
+
15
+ // Define smooth scroll
16
+ const lenis = new Lenis({
17
+ duration: 1.2,
18
+ easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t))
19
+ });
20
+
21
+ // Lenis scroll start function
22
+ function lenisScroll() {
23
+ function raf(time) {
24
+ lenis.raf(time);
25
+ requestAnimationFrame(raf);
26
+ }
27
+ requestAnimationFrame(raf);
28
+ }
29
+
30
+ // Lazy load library init
31
+ function lazyLoad() {
32
+ const observer = lozad('img, video:not(#fullReel)', {
33
+ loaded: function (el) {
34
+ // Custom code to run when an image or video is loaded
35
+ },
36
+ });
37
+ observer.observe();
38
+ }
39
+
40
+ // Custom ease for GSAP
41
+ function customGsapEasing(){
42
+ CustomEase.create('loader', '0.83, 0, 0.17, 1');
43
+ CustomEase.create('loader2', '0.77, 0, 0.175, 1');
44
+ }
45
+
46
+ // Reload page on browser back action
47
+ function reloadOnBack() {
48
+ window.addEventListener('pageshow', function (event) {
49
+ if (event.persisted) {
50
+ window.location.reload();
51
+ }
52
+ });
53
+ }
54
+
55
+ // Page load animation
56
+ const loaderAnimationIn = gsap.timeline({});
57
+ loaderAnimationIn.add(function() {
58
+ history.scrollRestoration = 'manual';
59
+ gsap.to(window, { duration: 0.05, scrollTo: 0 });
60
+ lenis.scrollTo(0);
61
+ });
62
+ loaderAnimationIn.add(function() {
63
+ lenis.stop();
64
+ }, '>');
65
+ loaderAnimationIn.to(
66
+ '.loader_ract',
67
+ {
68
+ delay: 0.2,
69
+ duration: 0.8,
70
+ width: 0,
71
+ ease: 'loader2',
72
+ },
73
+ '>'
74
+ );
75
+ loaderAnimationIn.add(function() {
76
+ lenis.start();
77
+ }, '>');
78
+ loaderAnimationIn.to('.loader_wrapper', { display: 'none', duration: 0.1 }, '>');
79
+
80
+ // Page transition animation
81
+ function transitionLinksRule() {
82
+ const transitionLinks = document.querySelectorAll(
83
+ 'a:not([href^="#"]):not([href^="javascript:"]):not([href=""]):not([href^="mailto:"]):not([href^="tel:"])'
84
+ );
85
+ transitionLinks.forEach((link) => {
86
+ if (link.getAttribute('target') !== '_blank') {
87
+ link.addEventListener('click', (e) => {
88
+ e.preventDefault();
89
+
90
+ const loaderAnimationOut = gsap.timeline({
91
+ onComplete: () => {
92
+ window.location.href = link.href;
93
+ },
94
+ });
95
+ loaderAnimationOut.to('.unloader_wrapper', { display: 'flex', duration: 0.05 });
96
+ loaderAnimationOut.from('.unloader_ract', {
97
+ duration: 0.4,
98
+ width: '0%',
99
+ ease: 'loader2',
100
+ }),
101
+ '>';
102
+ // play the timeline
103
+ loaderAnimationOut.play();
104
+ });
105
+ }
106
+ });
107
+ }
108
+
109
+ // Reset loader display on screen resize
110
+ function onScreenResize() {
111
+ window.addEventListener('resize', function () {
112
+ setTimeout(function () {
113
+ gsap.set('.loader_wrapper', { display: 'none' });
114
+ }, 50);
115
+ });
116
+ }
117
+
118
+ // Hero move to reveal footer
119
+ function revealFooter() {
120
+ gsap.to('#heroSection', {
121
+ scrollTrigger: {
122
+ trigger: '#bottomWrapper',
123
+ start: 'top bottom',
124
+ toggleActions: 'restart none none reverse',
125
+ },
126
+ y: '-100%',
127
+ });
128
+ }
129
+
130
+ // Custom cursor on mousedown and mouse up
131
+ function customCursorOnClick() {
132
+ const cursorElements = document.querySelectorAll('[wide="customCursor"]');
133
+ const customCursor = document.querySelector('.custom_cursor');
134
+ cursorElements.forEach((element) => {
135
+ element.addEventListener('mousedown', function () {
136
+ customCursor.style.transform = 'scale3d(0.8, 0.8, 1)';
137
+ });
138
+ element.addEventListener('mouseup', function () {
139
+ customCursor.style.transform = 'scale3d(1, 1, 1)';
140
+ });
141
+ });
142
+ }
143
+
144
+ // Custom cursor copy change on hover
145
+ function customCursorChangeCopy() {
146
+ document.addEventListener('DOMContentLoaded', function () {
147
+ const customCursorElements = document.querySelectorAll('[wideCursorText]');
148
+ customCursorElements.forEach(function (element) {
149
+ element.addEventListener('mouseenter', () => {
150
+ const wideCursorTextValue = element.getAttribute('wideCursorText');
151
+ const customCursorTextElement = document.querySelector('.custom_cursor_text');
152
+ customCursorTextElement.innerHTML = wideCursorTextValue;
153
+ });
154
+ });
155
+ });
156
+ }
157
+
158
+ // Header animations
159
+ const showHideHeader = gsap.from('.navbar', {
160
+ y: '-100%',
161
+ paused: true,
162
+ duration: 0.2,
163
+ ease: 'loader2',
164
+ })
165
+ .progress(1);
166
+
167
+ // Header animation on scroll
168
+ function headeronScroll() {
169
+ ScrollTrigger.create({
170
+ start: 'top top',
171
+ endTrigger: '.bottom-wrapper',
172
+ end: 'bottom top+=100px',
173
+ onUpdate: (self) => {
174
+ self.direction === -1 ? showHideHeader.play() : showHideHeader.reverse();
175
+ },
176
+ });
177
+ }
178
+
179
+ // Page load animation
180
+ const homeLoadAnimation = gsap.timeline({}),
181
+ homeHeroHeading = new SplitText('#homeHeroHeading', {
182
+ type: 'lines',
183
+ linesClass: 'hero-line',
184
+ }),
185
+ homeHeroHeadingMask = new SplitText('#homeHeroHeading', {
186
+ type: 'lines',
187
+ linesClass: 'hero-line-mask',
188
+ });
189
+ homeLoadAnimation.add(loaderAnimationIn.play());
190
+ homeLoadAnimation.from('.navbar', {
191
+ opacity: 0,
192
+ duration: 0.6,
193
+ ease: 'loader2',
194
+ }),
195
+ '>-2';
196
+ homeLoadAnimation.from(
197
+ '.hero-line',
198
+ {
199
+ duration: 1.2,
200
+ y: '100%',
201
+ stagger: 0.2,
202
+ ease: 'loader2',
203
+ },
204
+ '>-0.5'
205
+ );
206
+ homeLoadAnimation.to(
207
+ '.hero_headline_ract-mask',
208
+ {
209
+ width: '0%',
210
+ duration: 0.6,
211
+ ease: 'loader2',
212
+ },
213
+ '>-0.6'
214
+ );
215
+ homeLoadAnimation.from(
216
+ '#heroSubtitle',
217
+ {
218
+ opacity: 0,
219
+ duration: 1,
220
+ ease: 'loader2',
221
+ },
222
+ '>-0.4'
223
+ );
224
+
225
+ // Stats section healdine animation
226
+ const statsHeadlineAnimation = gsap.timeline({
227
+ scrollTrigger: {
228
+ trigger: '#statsKnow',
229
+ start: 'center center',
230
+ toggleActions: 'restart none none reverse',
231
+ end: '+=500',
232
+ },
233
+ pause: 'paused',
234
+ ease: 'defaultEase',
235
+ }),
236
+ homeStatsHeading = new SplitText('#statsDone', {
237
+ type: 'lines',
238
+ linesClass: 'stats-line',
239
+ }),
240
+ homeStatsHeadingMask = new SplitText('#statsDone', {
241
+ type: 'lines',
242
+ linesClass: 'stats-line-mask',
243
+ });
244
+ statsHeadlineAnimation.to(
245
+ '#statsKnow',
246
+ {
247
+ duration: 0.5,
248
+ opacity: 0,
249
+ display: 'none',
250
+ },
251
+ '>'
252
+ );
253
+ statsHeadlineAnimation.from('.stats-line', {
254
+ duration: 0.5,
255
+ opacity: 0,
256
+ y: '100%',
257
+ stagger: 0.25,
258
+ });
259
+
260
+ // Place the elements inside the H1 span for home hero section
261
+ const heroHeadlineContent = document.querySelector('.hero_headline-span.copy-this');
262
+ const heroHeadlineSpan = document.querySelector('.hero_headline-span');
263
+ heroHeadlineSpan.appendChild(heroHeadlineContent);
264
+
265
+ // Place the elements inside the H2 span for home reviews section
266
+ const reviewsHeadlineContent = document.querySelector('.reviews_headline-span.copy-this');
267
+ const reviewsHeadlineSpan = document.querySelector('.reviews_headline-span');
268
+ reviewsHeadlineSpan.appendChild(reviewsHeadlineContent);
269
+
270
+ // Place the elements inside the H2 span for home start section
271
+ const startHeadlineContent = document.querySelector('.start_headline-span.copy-this');
272
+ const startHeadlineSpan = document.querySelector('.start_headline-span');
273
+ startHeadlineSpan.appendChild(startHeadlineContent);
274
+
275
+ // Case study images mask animation
276
+ const csImageMasks = document.querySelectorAll('.portfolio_item_image-mask');
277
+ csImageMasks.forEach((mask) => {
278
+ const maskAnimation = gsap.from(mask, {
279
+ width: '100%',
280
+ duration: 0.72,
281
+ ease: 'loader2',
282
+ paused: true,
283
+ });
284
+ ScrollTrigger.create({
285
+ animation: maskAnimation,
286
+ trigger: mask,
287
+ start: 'top 80%',
288
+ onEnter: () => maskAnimation.play(),
289
+ });
290
+ });
291
+
292
+ // Reviews slider
293
+ // Put content of static slide into list
294
+ const staticContent = document.querySelector(
295
+ '.splide__slide.reviews_collection_item.is-static'
296
+ ).innerHTML;
297
+ const dynamicElement = document.querySelector('.reviews_collection_item');
298
+ dynamicElement.innerHTML = staticContent;
299
+ dynamicElement.classList.add('is-static');
300
+
301
+ // Reviews slider splide initialize
302
+ new Splide('#reviewsSlider', {
303
+ type: 'slide',
304
+ fixedWidth: '24.5rem',
305
+ focus: 0,
306
+ padding: { left: '2.5rem', right: 0 },
307
+ gap: 0,
308
+ omitEnd: true,
309
+ arrows: false,
310
+ drag: true,
311
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
312
+ snap: true,
313
+ classes: {
314
+ pagination: 'splide__pagination reviews-pagination',
315
+ page: 'splide__pagination__page reviews-page',
316
+ },
317
+ breakpoints: {
318
+ 992: { fixedWidth: '17.438rem', padding: { left: '1.75rem' }, drag: 'free', snap: false },
319
+ 480: { fixedWidth: '16.25rem', padding: { left: '1.375rem' }, drag: 'free', snap: false },
320
+ },
321
+ }).mount();
322
+
323
+ // Facts slider splide initialize
324
+ const factsSplide = new Splide('#factsSlider', {
325
+ type: 'loop',
326
+ perPage: 1,
327
+ gap: 0,
328
+ arrows: false,
329
+ drag: false,
330
+ duration: 0.15,
331
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
332
+ classes: {
333
+ pagination: 'splide__pagination facts-pagination',
334
+ page: 'splide__pagination__page facts-page',
335
+ },
336
+ breakpoints: {
337
+ 992: { gap: '1.75rem', drag: true },
338
+ 480: { gap: '1.375rem' },
339
+ },
340
+ }).mount();
341
+ // Next on click
342
+ if (window.innerWidth > 992) {
343
+ factsSplide.on('click', function () {
344
+ factsSplide.go('+1');
345
+ });
346
+ }
347
+ const externalLink = document.querySelectorAll('.external_link.is-cursor');
348
+ // Loop through each element and execute customCursorIn.reverse()
349
+ externalLink.forEach((link) => {
350
+ link.addEventListener('click', () => {
351
+ event.stopPropagation();
352
+ });
353
+ });
354
+ factsSplide.on('move ', (newIndex) => {
355
+ if (newIndex === 0) {
356
+ document.querySelector('.facts-slide_diagram-trigger.is-0').click();
357
+ } else if (newIndex === 1) {
358
+ document.querySelector('.facts-slide_diagram-trigger.is-1').click();
359
+ } else if (newIndex === 2) {
360
+ document.querySelector('.facts-slide_diagram-trigger.is-2').click();
361
+ }
362
+ });
363
+
364
+ ScrollTrigger.create({
365
+ trigger: '.section.is-facts',
366
+ start: 'top bottom',
367
+ once: true,
368
+ onToggle: () => {
369
+ document.querySelector('.facts-slide_diagram-trigger.is-0').click();
370
+ },
371
+ });
372
+
373
+ // Team slider splide initialize
374
+ new Splide('#teamSlider', {
375
+ type: 'slide',
376
+ fixedWidth: '20%',
377
+ padding: { left: '2.5rem', right: 0 },
378
+ focus: 0,
379
+ gap: 0,
380
+ pagination: false,
381
+ omitEnd: true,
382
+ arrows: false,
383
+ drag: true,
384
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
385
+ snap: true,
386
+ classes: {
387
+ pagination: 'splide__pagination facts-pagination',
388
+ page: 'splide__pagination__page facts-page',
389
+ },
390
+ breakpoints: {
391
+ 992: { fixedWidth: '40%', padding: { left: '1.75rem' }, drag: 'free', snap: false },
392
+ 560: { fixedWidth: '75%', padding: { left: '1.375rem' }, drag: 'free', snap: false },
393
+ },
394
+ }).mount();
395
+
396
+ // Reel video padding animation
397
+ gsap.to('#reelPrevSection', {
398
+ scrollTrigger: {
399
+ trigger: '#reelPrevSection',
400
+ start: 'top bottom',
401
+ end: 'top top',
402
+ toggleActions: 'restart none none reverse',
403
+ scrub: 1,
404
+ },
405
+ paddingLeft: '0rem',
406
+ paddingRight: '0rem',
407
+ ease: 'linear',
408
+ });
409
+
410
+ // Big team image padding animation
411
+ gsap.to('.team_big-image_wrapper', {
412
+ scrollTrigger: {
413
+ trigger: '.team_big-image_wrapper',
414
+ start: 'top bottom',
415
+ end: 'top top',
416
+ toggleActions: 'restart none none reverse',
417
+ scrub: 1,
418
+ },
419
+ paddingLeft: '0rem',
420
+ paddingRight: '0rem',
421
+ ease: 'linear',
422
+ });
423
+
424
+ // Sections bg animation
425
+
426
+ window.addEventListener('load', function () {
427
+ gsap.set('.section.is-skills', { backgroundColor: '#fff' });
428
+ gsap.set('#heroNavbarLottie path', { fill: 'rgb(21, 21, 21)' });
429
+ if (window.innerWidth > 992) {
430
+ const sectionsBgChange = gsap.timeline({
431
+ duration: 0.2,
432
+ ease: 'loader2',
433
+ scrollTrigger: {
434
+ trigger: '.section.is-skills',
435
+ start: 'top bottom',
436
+ end: 'bottom top',
437
+ toggleActions: 'restart reverse restart reverse',
438
+ },
439
+ });
440
+ sectionsBgChange.to(['#skills', '#portfolio'], {
441
+ backgroundColor: '#151515',
442
+ });
443
+ // Change navbar element on bg animation
444
+ sectionsBgChange.to(
445
+ [
446
+ '.navbar_menu_link',
447
+ '.button_small',
448
+ '.button_small_icon',
449
+ '.navbar_brand_svg',
450
+ '#heroNavbarLottie path ',
451
+ ],
452
+ {
453
+ color: '#fff',
454
+ fill: 'rgb(254, 254, 254)',
455
+ },
456
+ '<'
457
+ );
458
+ } else {
459
+ const sectionsBgChange = gsap.timeline({
460
+ duration: 0.2,
461
+ ease: 'loader2',
462
+ scrollTrigger: {
463
+ trigger: '.section.is-skills',
464
+ start: 'top bottom',
465
+ end: 'bottom top',
466
+ toggleActions: 'restart reverse restart reverse',
467
+ },
468
+ });
469
+ sectionsBgChange.to(['#skills', '#portfolio'], {
470
+ backgroundColor: '#151515',
471
+ });
472
+ // Change navbar element on bg animation
473
+ sectionsBgChange.to(
474
+ ['.button_small', '.button_small_icon', '.navbar_brand_svg', '#heroNavbarLottie path '],
475
+ {
476
+ color: '#fff',
477
+ fill: 'rgb(254, 254, 254)',
478
+ },
479
+ '<'
480
+ );
481
+ }
482
+ });
483
+
484
+ // Reviews span video mask
485
+ gsap.to('.reviews_headline_ract-mask', {
486
+ scrollTrigger: { trigger: '.reviews_headline_ract-mask', start: 'bottom bottom-=5%' },
487
+ width: 0,
488
+ ease: 'loader2',
489
+ duration: 0.6,
490
+ });
491
+
492
+ // Start span video mask
493
+ gsap.to('.start_headline_ract-mask', {
494
+ scrollTrigger: { trigger: '.start_headline_ract-mask', start: 'bottom bottom-=5%' },
495
+ width: 0,
496
+ ease: 'loader2',
497
+ duration: 0.6,
498
+ });
499
+
500
+ // Home starts section diagram animation
501
+ // Step 1 timeline
502
+ const startStep1 = gsap.timeline({ paused: true });
503
+ startStep1.fromTo(
504
+ '#startPath1',
505
+ {
506
+ drawSVG: '50%',
507
+ },
508
+ {
509
+ drawSVG: '0% 100%',
510
+ duration: 1,
511
+ ease: 'loader',
512
+ }
513
+ );
514
+ startStep1.from(
515
+ '#startIcon1',
516
+ {
517
+ opacity: 0,
518
+ duration: 0.3,
519
+ ease: 'loader',
520
+ },
521
+ '<0.1'
522
+ );
523
+ startStep1.from(
524
+ '#stepPoint1',
525
+ {
526
+ opacity: 0,
527
+ duration: 0.4,
528
+ ease: 'loader',
529
+ },
530
+ 0.8
531
+ );
532
+ startStep1.from(
533
+ '#startGradientMask',
534
+ {
535
+ height: '0px',
536
+ opacity: 0,
537
+ duration: 0.6,
538
+ ease: 'loader',
539
+ },
540
+ '-=0.8'
541
+ );
542
+ // Step 2 timeline
543
+ const startStep2 = gsap.timeline({ paused: true });
544
+ startStep2.fromTo(
545
+ '#startPath2',
546
+ {
547
+ drawSVG: '50%',
548
+ },
549
+ {
550
+ drawSVG: '0% 100%',
551
+ duration: 1,
552
+ ease: 'loader',
553
+ }
554
+ );
555
+ startStep2.from(
556
+ '#startIcon2',
557
+ {
558
+ opacity: 0,
559
+ duration: 0.3,
560
+ ease: 'loader',
561
+ },
562
+ '<0.1'
563
+ );
564
+ startStep2.from(
565
+ '#stepPoint2',
566
+ {
567
+ opacity: 0,
568
+ duration: 0.4,
569
+ ease: 'loader',
570
+ },
571
+ 0.8
572
+ );
573
+ // Step 3 timeline
574
+ const startStep3 = gsap.timeline({ paused: true });
575
+ startStep3.fromTo(
576
+ '#startPath3',
577
+ {
578
+ drawSVG: '50%',
579
+ },
580
+ {
581
+ drawSVG: '0% 100%',
582
+ duration: 1,
583
+ ease: 'loader',
584
+ }
585
+ );
586
+ startStep3.from(
587
+ '#startIcon3',
588
+ {
589
+ opacity: 0,
590
+ duration: 0.3,
591
+ ease: 'loader',
592
+ },
593
+ '<0.1'
594
+ );
595
+ startStep3.from(
596
+ '#stepPoint3',
597
+ {
598
+ opacity: 0,
599
+ duration: 0.4,
600
+ ease: 'loader',
601
+ },
602
+ 0.8
603
+ );
604
+ // Step 4 timeline
605
+ const startStep4 = gsap.timeline({ paused: true });
606
+ startStep4.fromTo(
607
+ '#startPath4',
608
+ {
609
+ drawSVG: '50%',
610
+ },
611
+ {
612
+ drawSVG: '0% 100%',
613
+ duration: 1,
614
+ ease: 'loader',
615
+ }
616
+ );
617
+ startStep4.from(
618
+ '#startIcon4',
619
+ {
620
+ opacity: 0,
621
+ duration: 0.3,
622
+ ease: 'loader',
623
+ },
624
+ '<0.1'
625
+ );
626
+ startStep4.from(
627
+ '#stepPoint4',
628
+ {
629
+ opacity: 0,
630
+ duration: 0.4,
631
+ ease: 'loader',
632
+ },
633
+ 0.8
634
+ );
635
+ // Whole animation timeline
636
+ const startDiagramAnimation = gsap.timeline({
637
+ scrollTrigger: {
638
+ trigger: '.section.is-start',
639
+ start: 'bottom 110%',
640
+ end: '+=500',
641
+ },
642
+ });
643
+ startDiagramAnimation.add(startStep1.play());
644
+ startDiagramAnimation.add(startStep2.play(), '-=0.4');
645
+ startDiagramAnimation.add(startStep3.play(), '-=0.4');
646
+ startDiagramAnimation.add(startStep4.play(), '-=0.4');
647
+
648
+ // Play cs item video on mouse hover
649
+ document.addEventListener('DOMContentLoaded', () => {
650
+ if (window.innerWidth > 992) {
651
+ const vid = document.querySelectorAll('.portfolio_item_image-wrapper');
652
+
653
+ vid.forEach((element) => {
654
+ const videoElements = element.getElementsByTagName('video');
655
+ const videoElement = videoElements.length > 0 ? videoElements[0] : null;
656
+ if (!videoElement) return;
657
+
658
+ videoElement.addEventListener('loadeddata', () => {
659
+ videoElement.pause();
660
+ });
661
+ element.addEventListener('mouseenter', hoverIN, false);
662
+ element.addEventListener('mouseleave', hoverOUT, false);
663
+
664
+ function hoverIN() {
665
+ videoElement.play();
666
+ }
667
+
668
+ function hoverOUT() {
669
+ videoElement.pause();
670
+ //videoElement.currentTime = 0;
671
+ }
672
+ });
673
+ } else {
674
+ const videoElems = document.querySelectorAll('.background-video video');
675
+
676
+ videoElems.forEach((videoElem) => {
677
+ const poster = videoElem.getAttribute('poster');
678
+ videoElem.innerHTML = '';
679
+ videoElem.setAttribute('poster', poster);
680
+ videoElem.load();
681
+ videoElem.pause();
682
+ });
683
+ }
684
+ });
685
+
686
+ // Randomize order of team slider
687
+ const teamList = document.querySelector('.team_collection_list');
688
+ const teamItems = Array.from(teamList.children);
689
+ teamItems.sort(function () {
690
+ return 0.5 - Math.random();
691
+ });
692
+ teamItems.forEach(function (item) {
693
+ teamList.appendChild(item);
694
+ });
695
+
696
+ // Clients logos in animation
697
+ const logosStagger = 0.15;
698
+ gsap.from('.clients_collection_item_mask', {
699
+ scrollTrigger: {
700
+ trigger: '.clients_collection_item_mask',
701
+ start: 'top bottom-=25%',
702
+ },
703
+ width: '0%',
704
+ duration: 0.7,
705
+ ease: 'loader2',
706
+ stagger: logosStagger,
707
+ });
708
+ gsap.from('.clients_item_image', {
709
+ scrollTrigger: {
710
+ trigger: '.clients_collection_item_mask',
711
+ start: 'top bottom-=25%',
712
+ },
713
+ opacity: 0,
714
+ delay: 0.4,
715
+ duration: 0.6,
716
+ ease: 'loader2',
717
+ stagger: logosStagger,
718
+ });
719
+
720
+ // Reviews slider animation in
721
+ gsap.from('.splide.is-reviews', {
722
+ scrollTrigger: {
723
+ trigger: '.splide.is-reviews',
724
+ start: 'top bottom',
725
+ end: 'bottom bottom-=15%',
726
+ scrub: 1,
727
+ once: true,
728
+ },
729
+ x: '10%',
730
+ opacity: 0,
731
+ ease: 'linear',
732
+ });
733
+
734
+ // Team slider animation in
735
+ gsap.from('.splide.is-team', {
736
+ scrollTrigger: {
737
+ trigger: '.splide.is-team',
738
+ start: 'top bottom',
739
+ end: 'bottom bottom',
740
+ scrub: 1,
741
+ once: true,
742
+ },
743
+ x: '10%',
744
+ opacity: 0,
745
+ ease: 'linear',
746
+ });
747
+
748
+ // Hover aimation - Michal
749
+ const michalHover = gsap.timeline({ paused: true, ease: 'loader2' });
750
+ michalHover.from('.team_big-image_person-wrapper.is-m', {
751
+ x: '5%',
752
+ opacity: 0,
753
+ duration: 0.4,
754
+ });
755
+ michalHover.from(
756
+ '#m-line',
757
+ {
758
+ drawSVG: '0% 0%',
759
+ duration: 0.2,
760
+ },
761
+ '>-0.2'
762
+ );
763
+ michalHover.from('#m-arrow', {
764
+ drawSVG: '0% 0%',
765
+ duration: 0.15,
766
+ }),
767
+ '>';
768
+ document.addEventListener('DOMContentLoaded', () => {
769
+ if (window.innerWidth > 992) {
770
+ const michalTriegger = document.querySelector('.team_big-image_trigger.is-m');
771
+ michalTriegger.addEventListener('mouseenter', () => {
772
+ michalHover.timeScale(1).play();
773
+ });
774
+ michalTriegger.addEventListener('mouseleave', () => {
775
+ michalHover.timeScale(3).reverse();
776
+ });
777
+ }
778
+ });
779
+
780
+ // Hover aimation - Michal
781
+ const krystianHover = gsap.timeline({ paused: true, ease: 'loader2' });
782
+ krystianHover.from('.team_big-image_person-wrapper.is-k', {
783
+ x: '5%',
784
+ opacity: 0,
785
+ duration: 0.4,
786
+ });
787
+ krystianHover.from(
788
+ '#k-line',
789
+ {
790
+ drawSVG: '0% 0%',
791
+ duration: 0.25,
792
+ },
793
+ '>-0.2'
794
+ );
795
+ krystianHover.from('#k-arrow', {
796
+ drawSVG: '0% 0%',
797
+ duration: 0.15,
798
+ }),
799
+ '>';
800
+ document.addEventListener('DOMContentLoaded', () => {
801
+ if (window.innerWidth > 992) {
802
+ const krystianTriegger = document.querySelector('.team_big-image_trigger.is-k');
803
+ krystianTriegger.addEventListener('mouseenter', () => {
804
+ krystianHover.timeScale(1).play();
805
+ });
806
+ krystianTriegger.addEventListener('mouseleave', () => {
807
+ krystianHover.timeScale(3).reverse();
808
+ });
809
+ }
810
+ });
811
+
812
+ // Hero span hover animation
813
+ const heroSpanContent = document.querySelector('.hero_headline-span');
814
+ const heroSpanContentAnimation = gsap.timeline({ paused: true, ease: 'loader2' });
815
+ heroSpanContentAnimation.to('.hero-line-mask', { clipPath: 'none', duration: 0.05 }, '>');
816
+ heroSpanContentAnimation.to(heroSpanContent, { scale: 2, duration: 0.35 }, '>');
817
+ document.addEventListener('DOMContentLoaded', () => {
818
+ if (window.innerWidth > 992) {
819
+ heroSpanContent.addEventListener('mouseenter', () => {
820
+ heroSpanContentAnimation.timeScale(1).play();
821
+ });
822
+ heroSpanContent.addEventListener('mouseleave', () => {
823
+ heroSpanContentAnimation.timeScale(2).reverse();
824
+ });
825
+ }
826
+ });
827
+
828
+ // Reel modal animation
829
+ const reelTrigger = document.querySelectorAll('[wideClick="playReel"]');
830
+ const reelModal = document.querySelector('.reel-modal');
831
+ const reelModalPlayer = document.getElementById('fullReel');
832
+ const reelPlayback = 0;
833
+ const reelModalShow = gsap.timeline({ ease: 'loader2', paused: true });
834
+ reelModalShow.to(reelModal, { display: 'flex', opacity: 0, duration: 0 });
835
+ reelModalShow.to(reelModal, { opacity: 1, duration: 0.6 }, '>');
836
+ if (window.innerWidth > 992) {
837
+ reelTrigger.forEach((element) => {
838
+ element.addEventListener('click', () => {
839
+ lenis.stop();
840
+ reelModalShow.timeScale(1).play();
841
+ // Set the video source based on whether the player can handle WebM
842
+ if (reelPlayback === 0) {
843
+ if (reelModalPlayer.canPlayType('video/webm')) {
844
+ reelModalPlayer.src =
845
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
846
+ } else {
847
+ reelModalPlayer.src =
848
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
849
+ }
850
+ // Load the video
851
+ reelModalPlayer.load();
852
+ } else {
853
+ return;
854
+ }
855
+
856
+ reelModalPlayer.play();
857
+ });
858
+ });
859
+ reelModal.addEventListener('click', () => {
860
+ reelModalShow.timeScale(4).reverse();
861
+ reelModalPlayer.pause();
862
+ lenis.start();
863
+ });
864
+ window.addEventListener('keydown', function (event) {
865
+ // The key code for the ESC key is 27
866
+ if (event.keyCode === 27) {
867
+ reelModalShow.timeScale(4).reverse();
868
+ reelModalPlayer.pause();
869
+ lenis.start();
870
+ }
871
+ });
872
+ } else {
873
+ reelTrigger.forEach((element) => {
874
+ element.addEventListener('click', () => {
875
+ // Set the video source based on whether the player can handle WebM
876
+ if (reelModalPlayer.canPlayType('video/webm')) {
877
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
878
+ } else {
879
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
880
+ }
881
+
882
+ // Load the video
883
+ reelModalPlayer.load();
884
+
885
+ // Add a listener to the 'canplaythrough' event
886
+ reelModalPlayer.addEventListener(
887
+ 'canplaythrough',
888
+ () => {
889
+ // Once there's enough data loaded to play through, start playback
890
+ reelModalPlayer.play();
891
+ },
892
+ { once: true }
893
+ ); // Ensure this event only fires once per click
894
+ });
895
+ });
896
+ reelModal.addEventListener('click', () => {
897
+ reelModalPlayer.pause();
898
+ });
899
+ }
900
+
901
+ // Map animation
902
+ const mapAnimation = gsap.timeline({
903
+ scrollTrigger: {
904
+ trigger: '.reviews_map_base',
905
+ start: 'bottom-=160px bottom',
906
+ },
907
+ });
908
+ mapAnimation.from('.map-point', {
909
+ duration: 1,
910
+ opacity: 0,
911
+ stagger: 0.1,
912
+ ease: 'loader2',
913
+ });
914
+ mapAnimation.from(
915
+ '.map-pin_wrapper',
916
+ {
917
+ duration: 1,
918
+ opacity: 0,
919
+ stagger: 0.1,
920
+ ease: 'loader2',
921
+ },
922
+ '0.3'
923
+ );
924
+
925
+ // Map pins animation on hover
926
+ const allMapPins = document.querySelectorAll('.map-pin_wrapper');
927
+ allMapPins.forEach(function (element) {
928
+ element.addEventListener('mouseenter', function () {
929
+ const mapPin = this.getAttribute('w-map-pin');
930
+ const oldPin = document.querySelectorAll('.map_info-collection-item');
931
+
932
+ const infoElements = document.querySelectorAll(
933
+ ".map_info-collection-item[w-map-info='" + mapPin + "']"
934
+ );
935
+ const infoElementsAppear = gsap.timeline({});
936
+ infoElementsAppear.to(oldPin, {
937
+ opacity: 0,
938
+ ease: 'loader2',
939
+ duration: 0.1,
940
+ });
941
+ infoElementsAppear.to(oldPin, {
942
+ display: 'none',
943
+ duration: 0.01,
944
+ });
945
+ infoElementsAppear.to(infoElements, {
946
+ display: 'block',
947
+ duration: 0.01,
948
+ });
949
+ infoElementsAppear.to(infoElements, {
950
+ opacity: 1,
951
+ ease: 'loader2',
952
+ duration: 0.2,
953
+ });
954
+ });
955
+ });
956
+
957
+ // Map boxes link special code
958
+ document.addEventListener('DOMContentLoaded', (event) => {
959
+ const elements = document.querySelectorAll('.map_info-wrapper');
960
+
961
+ for (let i = 0; i < elements.length; i++) {
962
+ const href = elements[i].getAttribute('href');
963
+ if (href && href.length > 3) {
964
+ elements[i].style.cursor = 'pointer';
965
+ }
966
+ }
967
+ });
968
+
969
+
2
970
 
3
- // Before you start:
4
- // 1. Change name and URL in package.json file
5
- // 2. Build and release to npm
6
- // 3. Replace the npm path in Webflow site custom footer code
7
- // 4. Remove these comments
8
971
 
9
972
 
10
- // -----> Write your functions here
11
973
 
12
974
 
13
975
 
@@ -19,4 +981,14 @@ import {initAlpine} from "./init";
19
981
  window.Webflow ||= [];
20
982
  window.Webflow.push(() => {
21
983
  initAlpine();
984
+ lenisScroll();
985
+ customGsapEasing();
986
+ lazyLoad();
987
+ reloadOnBack();
988
+ transitionLinksRule();
989
+ onScreenResize();
990
+ revealFooter();
991
+ customCursorOnClick();
992
+ customCursorChangeCopy();
993
+ headeronScroll();
22
994
  });