@widelab-nc/widelab 1.0.14 → 1.0.16

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
@@ -6,10 +6,11 @@ import { ScrollToPlugin } from "gsap/ScrollToPlugin";
6
6
  import { CustomEase } from "gsap/CustomEase";
7
7
  import { SplitText } from "gsap/SplitText";
8
8
  import Splide from '@splidejs/splide';
9
+ import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin';
9
10
 
10
11
 
11
12
  // GSAP plugins register and custom easing
12
- gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, CustomEase, SplitText);
13
+ gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, CustomEase, SplitText, DrawSVGPlugin);
13
14
  function customGsapEasing() {
14
15
  CustomEase.create('loader', '0.83, 0, 0.17, 1');
15
16
  CustomEase.create('loader2', '0.77, 0, 0.175, 1');
@@ -99,7 +100,7 @@ function customGsapEasing() {
99
100
  '.loader_ract',
100
101
  {
101
102
  delay: 0.2,
102
- duration: 0.8,
103
+ duration: 0.5,
103
104
  width: 0,
104
105
  ease: 'loader2',
105
106
  },
@@ -257,7 +258,8 @@ function customGsapEasing() {
257
258
  }
258
259
 
259
260
  // Case study mask animation
260
- window.caseStudyMaskAnimation = function(e) {
261
+ window.caseStudyInteraction = function(e) {
262
+ // Video mask animation
261
263
  const mask = e.querySelector('.portfolio_item_image-mask');
262
264
  const maskAnimation = gsap.from(mask, {
263
265
  width: '100%',
@@ -271,6 +273,36 @@ function customGsapEasing() {
271
273
  start: 'top 80%',
272
274
  onEnter: () => maskAnimation.play(),
273
275
  });
276
+
277
+ // Video on hover actions
278
+ const videoElements = e.getElementsByTagName('video');
279
+ if (window.innerWidth > 992) {
280
+ const videoElement = videoElements.length > 0 ? videoElements[0] : null;
281
+ if (!videoElement) return;
282
+
283
+ videoElement.addEventListener('loadeddata', () => {
284
+ videoElement.pause();
285
+ });
286
+ e.addEventListener('mouseenter', hoverIN, false);
287
+ e.addEventListener('mouseleave', hoverOUT, false);
288
+
289
+ function hoverIN() {
290
+ videoElement.play();
291
+ }
292
+
293
+ function hoverOUT() {
294
+ videoElement.pause();
295
+ //videoElement.currentTime = 0;
296
+ }
297
+ } else {
298
+ videoElements.forEach((videoElem) => {
299
+ const poster = videoElem.getAttribute('poster');
300
+ videoElem.innerHTML = '';
301
+ videoElem.setAttribute('poster', poster);
302
+ videoElem.load();
303
+ videoElem.pause();
304
+ });
305
+ }
274
306
  }
275
307
 
276
308
  // Reviews slider
@@ -312,83 +344,407 @@ function customGsapEasing() {
312
344
  reviewsSplide.go('+1');
313
345
  });
314
346
  }
347
+
348
+ // Animation in
349
+ gsap.from(e, {
350
+ scrollTrigger: {
351
+ trigger: e,
352
+ start: 'top bottom',
353
+ end: 'bottom bottom-=15%',
354
+ scrub: 1,
355
+ once: true,
356
+ },
357
+ x: '10%',
358
+ opacity: 0,
359
+ ease: 'linear',
360
+ });
315
361
  }
316
362
 
317
- // Facts slider
318
- window.factsSlider = function(e) {
319
- // Facts slider splide initialize
320
- const factsSplide = new Splide(e, {
321
- type: 'loop',
322
- perPage: 1,
323
- gap: 0,
324
- arrows: false,
325
- drag: false,
326
- duration: 0.15,
327
- easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
328
- classes: {
329
- pagination: 'splide__pagination facts-pagination',
330
- page: 'splide__pagination__page facts-page',
331
- },
332
- breakpoints: {
333
- 992: { gap: '1.75rem', drag: true },
334
- 480: { gap: '1.375rem' },
335
- },
336
- }).mount();
337
- // Next on click
338
- if (window.innerWidth > 992) {
339
- factsSplide.on('click', function () {
340
- factsSplide.go('+1');
363
+ // Facts slider
364
+ window.factsSlider = function(e) {
365
+ // Facts slider splide initialize
366
+ const factsSplide = new Splide(e, {
367
+ type: 'loop',
368
+ perPage: 1,
369
+ gap: 0,
370
+ arrows: false,
371
+ drag: false,
372
+ duration: 0.15,
373
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
374
+ classes: {
375
+ pagination: 'splide__pagination facts-pagination',
376
+ page: 'splide__pagination__page facts-page',
377
+ },
378
+ breakpoints: {
379
+ 992: { gap: '1.75rem', drag: true },
380
+ 480: { gap: '1.375rem' },
381
+ },
382
+ }).mount();
383
+ // Next on click
384
+ if (window.innerWidth > 992) {
385
+ factsSplide.on('click', function () {
386
+ factsSplide.go('+1');
387
+ });
388
+ }
389
+
390
+ // Click on external link
391
+ const externalLink = e.querySelectorAll('.external_link.is-cursor');
392
+ // Loop through each element and execute customCursorIn.reverse()
393
+ externalLink.forEach((link) => {
394
+ link.addEventListener('click', () => {
395
+ event.stopPropagation();
396
+ });
397
+ });
398
+
399
+ // Animations
400
+ factsSplide.on('move ', (newIndex) => {
401
+ if (newIndex === 0) {
402
+ document.querySelector('.facts-slide_diagram-trigger.is-0').click();
403
+ } else if (newIndex === 1) {
404
+ document.querySelector('.facts-slide_diagram-trigger.is-1').click();
405
+ } else if (newIndex === 2) {
406
+ document.querySelector('.facts-slide_diagram-trigger.is-2').click();
407
+ }
408
+ });
409
+ ScrollTrigger.create({
410
+ trigger: '.section.is-facts',
411
+ start: 'top bottom',
412
+ once: true,
413
+ onToggle: () => {
414
+ document.querySelector('.facts-slide_diagram-trigger.is-0').click();
415
+ },
341
416
  });
342
417
  }
343
- const externalLink = e.querySelectorAll('.external_link.is-cursor');
344
- // Loop through each element and execute customCursorIn.reverse()
345
- externalLink.forEach((link) => {
346
- link.addEventListener('click', () => {
347
- event.stopPropagation();
418
+
419
+ // Team slider
420
+ window.teamSlider = function(e) {
421
+ // Randomize order of slides
422
+ const teamList = e.querySelector('.team_collection_list');
423
+ const teamItems = Array.from(teamList.children);
424
+ teamItems.sort(function () {
425
+ return 0.5 - Math.random();
426
+ });
427
+ teamItems.forEach(function (item) {
428
+ teamList.appendChild(item);
348
429
  });
349
- });
350
- }
351
430
 
352
- // Team slider
353
- window.teamSlider = function(e) {
354
- new Splide(e, {
355
- type: 'slide',
356
- fixedWidth: '20%',
357
- padding: { left: '2.5rem', right: 0 },
358
- focus: 0,
359
- gap: 0,
360
- pagination: false,
361
- omitEnd: true,
362
- arrows: false,
363
- drag: true,
364
- easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
365
- snap: true,
366
- classes: {
367
- pagination: 'splide__pagination facts-pagination',
368
- page: 'splide__pagination__page facts-page',
369
- },
370
- breakpoints: {
371
- 992: { fixedWidth: '40%', padding: { left: '1.75rem' }, drag: 'free', snap: false },
372
- 560: { fixedWidth: '75%', padding: { left: '1.375rem' }, drag: 'free', snap: false },
373
- },
374
- }).mount();
375
- }
431
+ // Team slider splide initialize
432
+ new Splide(e, {
433
+ type: 'slide',
434
+ fixedWidth: '20%',
435
+ padding: { left: '2.5rem', right: 0 },
436
+ focus: 0,
437
+ gap: 0,
438
+ pagination: false,
439
+ omitEnd: true,
440
+ arrows: false,
441
+ drag: true,
442
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
443
+ snap: true,
444
+ classes: {
445
+ pagination: 'splide__pagination facts-pagination',
446
+ page: 'splide__pagination__page facts-page',
447
+ },
448
+ breakpoints: {
449
+ 992: { fixedWidth: '40%', padding: { left: '1.75rem' }, drag: 'free', snap: false },
450
+ 560: { fixedWidth: '75%', padding: { left: '1.375rem' }, drag: 'free', snap: false },
451
+ },
452
+ }).mount();
453
+
454
+ // Animation in
455
+ gsap.from(e, {
456
+ scrollTrigger: {
457
+ trigger: e,
458
+ start: 'top bottom',
459
+ end: 'bottom bottom',
460
+ scrub: 1,
461
+ once: true,
462
+ },
463
+ x: '10%',
464
+ opacity: 0,
465
+ ease: 'linear',
466
+ });
467
+ }
468
+
469
+ // Element padding change on scroll
470
+ window.elementPaddingChange = function(e) {
471
+ gsap.to(e, {
472
+ scrollTrigger: {
473
+ trigger: e,
474
+ start: 'top bottom',
475
+ end: 'top top',
476
+ toggleActions: 'restart none none reverse',
477
+ scrub: 1,
478
+ },
479
+ paddingLeft: '0rem',
480
+ paddingRight: '0rem',
481
+ ease: 'linear',
482
+ });
483
+ }
484
+
485
+ // Section bg change
486
+ window.sectionBgChange = function(e) {
487
+ gsap.set(e, { backgroundColor: '#fff' });
488
+ gsap.set('#heroNavbarLottie path', { fill: 'rgb(21, 21, 21)' });
489
+ const sectionsBgChange = gsap.timeline({
490
+ duration: 0.3,
491
+ ease: 'loader2',
492
+ scrollTrigger: {
493
+ trigger: e,
494
+ start: 'top bottom',
495
+ end: 'bottom top',
496
+ toggleActions: 'play reverse play reverse',
497
+ },
498
+ });
499
+ sectionsBgChange.to(['#skills', '#portfolio'], {
500
+ backgroundColor: '#151515',
501
+ });
502
+ // Change navbar element on bg animation
503
+ sectionsBgChange.to(
504
+ [
505
+ '.button_small',
506
+ '.button_small_icon',
507
+ '.navbar_brand_svg',
508
+ '#heroNavbarLottie path ',
509
+ ],
510
+ {
511
+ color: '#fff',
512
+ fill: 'rgb(254, 254, 254)',
513
+ },
514
+ '<'
515
+ );
516
+ if (window.innerWidth > 992) {
517
+ sectionsBgChange.to(
518
+ '.navbar_menu_link',
519
+ {
520
+ color: '#fff',
521
+ fill: 'rgb(254, 254, 254)',
522
+ },
523
+ '<'
524
+ );
525
+ }
526
+ }
527
+
528
+ // Client logos animation
529
+ window.clientLogosAnimation = function(e) {
530
+ const logosStagger = 0.15;
531
+ const logoMask = e.querySelectorAll('[class*="item_mask"]');
532
+ const logoImg = e.querySelectorAll('[class*="image"]');
533
+ gsap.from(logoMask, {
534
+ scrollTrigger: {
535
+ trigger: logoMask,
536
+ start: 'top bottom-=25%',
537
+ },
538
+ width: '0%',
539
+ duration: 0.7,
540
+ ease: 'loader2',
541
+ stagger: logosStagger,
542
+ });
543
+ gsap.from(logoImg, {
544
+ scrollTrigger: {
545
+ trigger: logoMask,
546
+ start: 'top bottom-=25%',
547
+ },
548
+ opacity: 0,
549
+ delay: 0.4,
550
+ duration: 0.45,
551
+ ease: 'loader2',
552
+ stagger: logosStagger,
553
+ });
554
+ }
555
+
556
+ // Hero span video on hover
557
+ window.heroSpanVideoOnHover = function(e) {
558
+ window.customCursorText(e);
559
+ const heroSpanContentAnimation = gsap.timeline({ paused: true, ease: 'loader2' });
560
+ heroSpanContentAnimation.to('.hero-line-mask', { clipPath: 'none', duration: 0.05 }, '>');
561
+ heroSpanContentAnimation.to(e, { scale: 2, duration: 0.35 }, '>');
562
+ if (window.innerWidth > 992) {
563
+ e.addEventListener('mouseenter', () => {
564
+ heroSpanContentAnimation.timeScale(1).play();
565
+ });
566
+ e.addEventListener('mouseleave', () => {
567
+ heroSpanContentAnimation.timeScale(2).reverse();
568
+ });
569
+ }
570
+ }
571
+
572
+ // Reel modal
573
+ window.reelModal = function() {
574
+ const reelTrigger = document.querySelectorAll('[wideClick="playReel"]');
575
+ const reelModal = document.querySelector('.reel-modal');
576
+ const reelModalPlayer = document.getElementById('fullReel');
577
+ const reelPlayback = 0;
578
+ const reelModalShow = gsap.timeline({ ease: 'loader2', paused: true });
579
+ reelModalShow.to(reelModal, { display: 'flex', opacity: 0, duration: 0 });
580
+ reelModalShow.to(reelModal, { opacity: 1, duration: 0.6 }, '>');
581
+ if (window.innerWidth > 992) {
582
+ reelTrigger.forEach((element) => {
583
+ element.addEventListener('click', () => {
584
+ lenis.stop();
585
+ reelModalShow.timeScale(1).play();
586
+ // Set the video source based on whether the player can handle WebM
587
+ if (reelPlayback === 0) {
588
+ if (reelModalPlayer.canPlayType('video/webm')) {
589
+ reelModalPlayer.src =
590
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
591
+ } else {
592
+ reelModalPlayer.src =
593
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
594
+ }
595
+ // Load the video
596
+ reelModalPlayer.load();
597
+ } else {
598
+ return;
599
+ }
600
+
601
+ reelModalPlayer.play();
602
+ });
603
+ });
604
+ reelModal.addEventListener('click', () => {
605
+ reelModalShow.timeScale(4).reverse();
606
+ reelModalPlayer.pause();
607
+ lenis.start();
608
+ });
609
+ window.addEventListener('keydown', function (event) {
610
+ // The key code for the ESC key is 27
611
+ if (event.keyCode === 27) {
612
+ reelModalShow.timeScale(4).reverse();
613
+ reelModalPlayer.pause();
614
+ lenis.start();
615
+ }
616
+ });
617
+ } else {
618
+ reelTrigger.forEach((element) => {
619
+ element.addEventListener('click', () => {
620
+ // Set the video source based on whether the player can handle WebM
621
+ if (reelModalPlayer.canPlayType('video/webm')) {
622
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
623
+ } else {
624
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
625
+ }
626
+
627
+ // Load the video
628
+ reelModalPlayer.load();
629
+
630
+ // Add a listener to the 'canplaythrough' event
631
+ reelModalPlayer.addEventListener(
632
+ 'canplaythrough',
633
+ () => {
634
+ // Once there's enough data loaded to play through, start playback
635
+ reelModalPlayer.play();
636
+ },
637
+ { once: true }
638
+ ); // Ensure this event only fires once per click
639
+ });
640
+ });
641
+ reelModal.addEventListener('click', () => {
642
+ reelModalPlayer.pause();
643
+ });
644
+ }
645
+ }
646
+
647
+ // Founders tooltip
648
+ window.foundersTooltip = function(e) {
649
+ const line = e.querySelector('.line');
650
+ const arrow = e.querySelector('.arrow');
651
+ const foundersHover = gsap.timeline({ paused: true, ease: 'loader2' });
652
+ foundersHover.from(e, {
653
+ x: '5%',
654
+ opacity: 0,
655
+ duration: 0.4,
656
+ });
657
+ foundersHover.from(
658
+ line,
659
+ {
660
+ drawSVG: '0% 0%',
661
+ duration: 0.2,
662
+ },
663
+ '>-0.2'
664
+ );
665
+ foundersHover.from(arrow, {
666
+ drawSVG: '0% 0%',
667
+ duration: 0.15,
668
+ }),
669
+ '>';
670
+ if (window.innerWidth > 992) {
671
+ e.addEventListener('mouseenter', () => {
672
+ foundersHover.timeScale(1).play();
673
+ });
674
+ e.addEventListener('mouseleave', () => {
675
+ foundersHover.timeScale(3).reverse();
676
+ });
677
+ }
678
+ }
679
+
680
+ // Clients map actions
681
+ window.clientsMapActions = function(e) {
682
+ // Map animation
683
+ const mapAnimation = gsap.timeline({
684
+ scrollTrigger: {
685
+ trigger: '.reviews_map_base',
686
+ start: 'bottom-=160px bottom',
687
+ },
688
+ });
689
+ mapAnimation.from('.map-point', {
690
+ duration: 1,
691
+ opacity: 0,
692
+ stagger: 0.1,
693
+ ease: 'loader2',
694
+ });
695
+ mapAnimation.from(
696
+ '.map-pin_wrapper',
697
+ {
698
+ duration: 1,
699
+ opacity: 0,
700
+ stagger: 0.1,
701
+ ease: 'loader2',
702
+ },
703
+ '0.3'
704
+ );
705
+
706
+ // Map pins animation on hover
707
+ const allMapPins = document.querySelectorAll('.map-pin_wrapper');
708
+ allMapPins.forEach(function (element) {
709
+ element.addEventListener('mouseenter', function () {
710
+ const mapPin = this.getAttribute('w-map-pin');
711
+ const oldPin = document.querySelectorAll('.map_info-collection-item');
712
+ const infoElements = document.querySelectorAll(
713
+ ".map_info-collection-item[w-map-info='" + mapPin + "']"
714
+ );
715
+ const infoElementsAppear = gsap.timeline({});
716
+ infoElementsAppear.to(oldPin, {
717
+ opacity: 0,
718
+ ease: 'loader2',
719
+ duration: 0.1,
720
+ });
721
+ infoElementsAppear.to(oldPin, {
722
+ display: 'none',
723
+ duration: 0.01,
724
+ });
725
+ infoElementsAppear.to(infoElements, {
726
+ display: 'block',
727
+ duration: 0.01,
728
+ });
729
+ infoElementsAppear.to(infoElements, {
730
+ opacity: 1,
731
+ ease: 'loader2',
732
+ duration: 0.2,
733
+ });
734
+ });
735
+ });
736
+ // Map boxes link special code
737
+ document.addEventListener('DOMContentLoaded', (event) => {
738
+ const elements = document.querySelectorAll('.map_info-wrapper');
739
+ for (let i = 0; i < elements.length; i++) {
740
+ const href = elements[i].getAttribute('href');
741
+ if (href && href.length > 3) {
742
+ elements[i].style.cursor = 'pointer';
743
+ }
744
+ }
745
+ });
746
+ }
376
747
 
377
- // Element padding change on scroll
378
- window.elementPaddingChange = function(e) {
379
- gsap.to(e, {
380
- scrollTrigger: {
381
- trigger: e,
382
- start: 'top bottom',
383
- end: 'top top',
384
- toggleActions: 'restart none none reverse',
385
- scrub: 1,
386
- },
387
- paddingLeft: '0rem',
388
- paddingRight: '0rem',
389
- ease: 'linear',
390
- });
391
- }
392
748
 
393
749
  // !!!!!!!!! Keep this Alpine init at the end !!!!!!!!!
394
750
  window.Webflow ||= [];
@@ -413,5 +769,4 @@ window.elementPaddingChange = function(e) {
413
769
  if (window.innerWidth < 992) {
414
770
  disableScrollMenu();
415
771
  }
416
-
417
772
  });