@widelab-nc/widelab 1.0.14 → 1.0.15

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,385 @@ 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
+ const externalLink = e.querySelectorAll('.external_link.is-cursor');
390
+ // Loop through each element and execute customCursorIn.reverse()
391
+ externalLink.forEach((link) => {
392
+ link.addEventListener('click', () => {
393
+ event.stopPropagation();
394
+ });
341
395
  });
342
396
  }
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();
397
+
398
+ // Team slider
399
+ window.teamSlider = function(e) {
400
+ new Splide(e, {
401
+ type: 'slide',
402
+ fixedWidth: '20%',
403
+ padding: { left: '2.5rem', right: 0 },
404
+ focus: 0,
405
+ gap: 0,
406
+ pagination: false,
407
+ omitEnd: true,
408
+ arrows: false,
409
+ drag: true,
410
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
411
+ snap: true,
412
+ classes: {
413
+ pagination: 'splide__pagination facts-pagination',
414
+ page: 'splide__pagination__page facts-page',
415
+ },
416
+ breakpoints: {
417
+ 992: { fixedWidth: '40%', padding: { left: '1.75rem' }, drag: 'free', snap: false },
418
+ 560: { fixedWidth: '75%', padding: { left: '1.375rem' }, drag: 'free', snap: false },
419
+ },
420
+ }).mount();
421
+
422
+ // Randomize order of slides
423
+ const teamList = e.querySelector('.team_collection_list');
424
+ const teamItems = Array.from(teamList.children);
425
+ teamItems.sort(function () {
426
+ return 0.5 - Math.random();
427
+ });
428
+ teamItems.forEach(function (item) {
429
+ teamList.appendChild(item);
348
430
  });
349
- });
350
- }
351
431
 
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
- }
432
+ // Animation in
433
+ gsap.from(e, {
434
+ scrollTrigger: {
435
+ trigger: e,
436
+ start: 'top bottom',
437
+ end: 'bottom bottom',
438
+ scrub: 1,
439
+ once: true,
440
+ },
441
+ x: '10%',
442
+ opacity: 0,
443
+ ease: 'linear',
444
+ });
445
+ }
446
+
447
+ // Element padding change on scroll
448
+ window.elementPaddingChange = function(e) {
449
+ gsap.to(e, {
450
+ scrollTrigger: {
451
+ trigger: e,
452
+ start: 'top bottom',
453
+ end: 'top top',
454
+ toggleActions: 'restart none none reverse',
455
+ scrub: 1,
456
+ },
457
+ paddingLeft: '0rem',
458
+ paddingRight: '0rem',
459
+ ease: 'linear',
460
+ });
461
+ }
462
+
463
+ // Section bg change
464
+ window.sectionBgChange = function(e) {
465
+ gsap.set(e, { backgroundColor: '#fff' });
466
+ gsap.set('#heroNavbarLottie path', { fill: 'rgb(21, 21, 21)' });
467
+ const sectionsBgChange = gsap.timeline({
468
+ duration: 0.3,
469
+ ease: 'loader2',
470
+ scrollTrigger: {
471
+ trigger: e,
472
+ start: 'top bottom',
473
+ end: 'bottom top',
474
+ toggleActions: 'play reverse play reverse',
475
+ },
476
+ });
477
+ sectionsBgChange.to(['#skills', '#portfolio'], {
478
+ backgroundColor: '#151515',
479
+ });
480
+ // Change navbar element on bg animation
481
+ sectionsBgChange.to(
482
+ [
483
+ '.button_small',
484
+ '.button_small_icon',
485
+ '.navbar_brand_svg',
486
+ '#heroNavbarLottie path ',
487
+ ],
488
+ {
489
+ color: '#fff',
490
+ fill: 'rgb(254, 254, 254)',
491
+ },
492
+ '<'
493
+ );
494
+ if (window.innerWidth > 992) {
495
+ sectionsBgChange.to(
496
+ '.navbar_menu_link',
497
+ {
498
+ color: '#fff',
499
+ fill: 'rgb(254, 254, 254)',
500
+ },
501
+ '<'
502
+ );
503
+ }
504
+ }
505
+
506
+ // Client logos animation
507
+ window.clientLogosAnimation = function(e) {
508
+ const logosStagger = 0.15;
509
+ const logoMask = e.querySelectorAll('[class*="item_mask"]');
510
+ const logoImg = e.querySelectorAll('[class*="image"]');
511
+ gsap.from(logoMask, {
512
+ scrollTrigger: {
513
+ trigger: logoMask,
514
+ start: 'top bottom-=25%',
515
+ },
516
+ width: '0%',
517
+ duration: 0.7,
518
+ ease: 'loader2',
519
+ stagger: logosStagger,
520
+ });
521
+ gsap.from(logoImg, {
522
+ scrollTrigger: {
523
+ trigger: logoMask,
524
+ start: 'top bottom-=25%',
525
+ },
526
+ opacity: 0,
527
+ delay: 0.4,
528
+ duration: 0.45,
529
+ ease: 'loader2',
530
+ stagger: logosStagger,
531
+ });
532
+ }
533
+
534
+ // Hero span video on hover
535
+ window.heroSpanVideoOnHover = function(e) {
536
+ window.customCursorText(e);
537
+ const heroSpanContentAnimation = gsap.timeline({ paused: true, ease: 'loader2' });
538
+ heroSpanContentAnimation.to('.hero-line-mask', { clipPath: 'none', duration: 0.05 }, '>');
539
+ heroSpanContentAnimation.to(e, { scale: 2, duration: 0.35 }, '>');
540
+ if (window.innerWidth > 992) {
541
+ e.addEventListener('mouseenter', () => {
542
+ heroSpanContentAnimation.timeScale(1).play();
543
+ });
544
+ e.addEventListener('mouseleave', () => {
545
+ heroSpanContentAnimation.timeScale(2).reverse();
546
+ });
547
+ }
548
+ }
549
+
550
+ // Reel modal
551
+ window.reelModal = function() {
552
+ const reelTrigger = document.querySelectorAll('[wideClick="playReel"]');
553
+ const reelModal = document.querySelector('.reel-modal');
554
+ const reelModalPlayer = document.getElementById('fullReel');
555
+ const reelPlayback = 0;
556
+ const reelModalShow = gsap.timeline({ ease: 'loader2', paused: true });
557
+ reelModalShow.to(reelModal, { display: 'flex', opacity: 0, duration: 0 });
558
+ reelModalShow.to(reelModal, { opacity: 1, duration: 0.6 }, '>');
559
+ if (window.innerWidth > 992) {
560
+ reelTrigger.forEach((element) => {
561
+ element.addEventListener('click', () => {
562
+ lenis.stop();
563
+ reelModalShow.timeScale(1).play();
564
+ // Set the video source based on whether the player can handle WebM
565
+ if (reelPlayback === 0) {
566
+ if (reelModalPlayer.canPlayType('video/webm')) {
567
+ reelModalPlayer.src =
568
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
569
+ } else {
570
+ reelModalPlayer.src =
571
+ 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
572
+ }
573
+ // Load the video
574
+ reelModalPlayer.load();
575
+ } else {
576
+ return;
577
+ }
578
+
579
+ reelModalPlayer.play();
580
+ });
581
+ });
582
+ reelModal.addEventListener('click', () => {
583
+ reelModalShow.timeScale(4).reverse();
584
+ reelModalPlayer.pause();
585
+ lenis.start();
586
+ });
587
+ window.addEventListener('keydown', function (event) {
588
+ // The key code for the ESC key is 27
589
+ if (event.keyCode === 27) {
590
+ reelModalShow.timeScale(4).reverse();
591
+ reelModalPlayer.pause();
592
+ lenis.start();
593
+ }
594
+ });
595
+ } else {
596
+ reelTrigger.forEach((element) => {
597
+ element.addEventListener('click', () => {
598
+ // Set the video source based on whether the player can handle WebM
599
+ if (reelModalPlayer.canPlayType('video/webm')) {
600
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.webm';
601
+ } else {
602
+ reelModalPlayer.src = 'https://widelabco.sfo3.cdn.digitaloceanspaces.com/Widelab-reel.mp4';
603
+ }
604
+
605
+ // Load the video
606
+ reelModalPlayer.load();
607
+
608
+ // Add a listener to the 'canplaythrough' event
609
+ reelModalPlayer.addEventListener(
610
+ 'canplaythrough',
611
+ () => {
612
+ // Once there's enough data loaded to play through, start playback
613
+ reelModalPlayer.play();
614
+ },
615
+ { once: true }
616
+ ); // Ensure this event only fires once per click
617
+ });
618
+ });
619
+ reelModal.addEventListener('click', () => {
620
+ reelModalPlayer.pause();
621
+ });
622
+ }
623
+ }
624
+
625
+ // Founders tooltip
626
+ window.foundersTooltip = function(e) {
627
+ const line = e.querySelector('.line');
628
+ const arrow = e.querySelector('.arrow');
629
+ const foundersHover = gsap.timeline({ paused: true, ease: 'loader2' });
630
+ foundersHover.from(e, {
631
+ x: '5%',
632
+ opacity: 0,
633
+ duration: 0.4,
634
+ });
635
+ foundersHover.from(
636
+ line,
637
+ {
638
+ drawSVG: '0% 0%',
639
+ duration: 0.2,
640
+ },
641
+ '>-0.2'
642
+ );
643
+ foundersHover.from(arrow, {
644
+ drawSVG: '0% 0%',
645
+ duration: 0.15,
646
+ }),
647
+ '>';
648
+ if (window.innerWidth > 992) {
649
+ e.addEventListener('mouseenter', () => {
650
+ foundersHover.timeScale(1).play();
651
+ });
652
+ e.addEventListener('mouseleave', () => {
653
+ foundersHover.timeScale(3).reverse();
654
+ });
655
+ }
656
+ }
657
+
658
+ // Clients map actions
659
+ window.clientsMapActions = function(e) {
660
+ // Map animation
661
+ const mapAnimation = gsap.timeline({
662
+ scrollTrigger: {
663
+ trigger: '.reviews_map_base',
664
+ start: 'bottom-=160px bottom',
665
+ },
666
+ });
667
+ mapAnimation.from('.map-point', {
668
+ duration: 1,
669
+ opacity: 0,
670
+ stagger: 0.1,
671
+ ease: 'loader2',
672
+ });
673
+ mapAnimation.from(
674
+ '.map-pin_wrapper',
675
+ {
676
+ duration: 1,
677
+ opacity: 0,
678
+ stagger: 0.1,
679
+ ease: 'loader2',
680
+ },
681
+ '0.3'
682
+ );
683
+
684
+ // Map pins animation on hover
685
+ const allMapPins = document.querySelectorAll('.map-pin_wrapper');
686
+ allMapPins.forEach(function (element) {
687
+ element.addEventListener('mouseenter', function () {
688
+ const mapPin = this.getAttribute('w-map-pin');
689
+ const oldPin = document.querySelectorAll('.map_info-collection-item');
690
+ const infoElements = document.querySelectorAll(
691
+ ".map_info-collection-item[w-map-info='" + mapPin + "']"
692
+ );
693
+ const infoElementsAppear = gsap.timeline({});
694
+ infoElementsAppear.to(oldPin, {
695
+ opacity: 0,
696
+ ease: 'loader2',
697
+ duration: 0.1,
698
+ });
699
+ infoElementsAppear.to(oldPin, {
700
+ display: 'none',
701
+ duration: 0.01,
702
+ });
703
+ infoElementsAppear.to(infoElements, {
704
+ display: 'block',
705
+ duration: 0.01,
706
+ });
707
+ infoElementsAppear.to(infoElements, {
708
+ opacity: 1,
709
+ ease: 'loader2',
710
+ duration: 0.2,
711
+ });
712
+ });
713
+ });
714
+ // Map boxes link special code
715
+ document.addEventListener('DOMContentLoaded', (event) => {
716
+ const elements = document.querySelectorAll('.map_info-wrapper');
717
+ for (let i = 0; i < elements.length; i++) {
718
+ const href = elements[i].getAttribute('href');
719
+ if (href && href.length > 3) {
720
+ elements[i].style.cursor = 'pointer';
721
+ }
722
+ }
723
+ });
724
+ }
376
725
 
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
726
 
393
727
  // !!!!!!!!! Keep this Alpine init at the end !!!!!!!!!
394
728
  window.Webflow ||= [];
@@ -413,5 +747,4 @@ window.elementPaddingChange = function(e) {
413
747
  if (window.innerWidth < 992) {
414
748
  disableScrollMenu();
415
749
  }
416
-
417
750
  });