@widelab-nc/widelab 1.0.13 → 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
@@ -5,10 +5,12 @@ import { ScrollTrigger } from "gsap/ScrollTrigger";
5
5
  import { ScrollToPlugin } from "gsap/ScrollToPlugin";
6
6
  import { CustomEase } from "gsap/CustomEase";
7
7
  import { SplitText } from "gsap/SplitText";
8
+ import Splide from '@splidejs/splide';
9
+ import { DrawSVGPlugin } from 'gsap/DrawSVGPlugin';
8
10
 
9
11
 
10
12
  // GSAP plugins register and custom easing
11
- gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, CustomEase, SplitText);
13
+ gsap.registerPlugin(ScrollTrigger, ScrollToPlugin, CustomEase, SplitText, DrawSVGPlugin);
12
14
  function customGsapEasing() {
13
15
  CustomEase.create('loader', '0.83, 0, 0.17, 1');
14
16
  CustomEase.create('loader2', '0.77, 0, 0.175, 1');
@@ -98,7 +100,7 @@ function customGsapEasing() {
98
100
  '.loader_ract',
99
101
  {
100
102
  delay: 0.2,
101
- duration: 0.8,
103
+ duration: 0.5,
102
104
  width: 0,
103
105
  ease: 'loader2',
104
106
  },
@@ -153,6 +155,20 @@ function customGsapEasing() {
153
155
  ease: 'loader2',
154
156
  }).progress(1);
155
157
 
158
+ // Custom cursor on mousedown and mouseup
159
+ function customCursorOnClick() {
160
+ const cursorElements = document.querySelectorAll('[wide="customCursor"]');
161
+ const customCursor = document.querySelector('.custom_cursor');
162
+ cursorElements.forEach((element) => {
163
+ element.addEventListener('mousedown', function () {
164
+ customCursor.style.transform = 'scale3d(0.8, 0.8, 1)';
165
+ });
166
+ element.addEventListener('mouseup', function () {
167
+ customCursor.style.transform = 'scale3d(1, 1, 1)';
168
+ });
169
+ });
170
+ }
171
+
156
172
  // Header scroll trigger
157
173
  window.standardHeaderScrollAnimation = function() {
158
174
  ScrollTrigger.create({
@@ -242,7 +258,8 @@ function customGsapEasing() {
242
258
  }
243
259
 
244
260
  // Case study mask animation
245
- window.caseStudyMaskAnimation = function(e) {
261
+ window.caseStudyInteraction = function(e) {
262
+ // Video mask animation
246
263
  const mask = e.querySelector('.portfolio_item_image-mask');
247
264
  const maskAnimation = gsap.from(mask, {
248
265
  width: '100%',
@@ -256,16 +273,461 @@ function customGsapEasing() {
256
273
  start: 'top 80%',
257
274
  onEnter: () => maskAnimation.play(),
258
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
+ }
259
306
  }
260
307
 
261
308
  // Reviews slider
262
309
  window.reviewsSlider = function(e) {
310
+ // Put content of static slide into list
311
+ const staticContent = e.querySelector(
312
+ '.splide__slide.reviews_collection_item.is-static'
313
+ ).innerHTML;
314
+ const dynamicElement = e.querySelector('.reviews_collection_item');
315
+ dynamicElement.innerHTML = staticContent;
316
+ dynamicElement.classList.add('is-static');
317
+
318
+ // Init reviews splide
319
+ const reviewsSplide = new Splide(e, {
320
+ type: 'slide',
321
+ fixedWidth: '24.5rem',
322
+ rewind: true,
323
+ focus: 0,
324
+ padding: { left: '2.5rem', right: 0 },
325
+ gap: 0,
326
+ omitEnd: true,
327
+ arrows: false,
328
+ drag: false,
329
+ easing: 'cubic-bezier(0.83, 0, 0.17, 1)',
330
+ snap: true,
331
+ classes: {
332
+ pagination: 'splide__pagination reviews-pagination',
333
+ page: 'splide__pagination__page reviews-page',
334
+ },
335
+ breakpoints: {
336
+ 992: { fixedWidth: '17.438rem', padding: { left: '1.75rem' }, drag: 'free', snap: false },
337
+ 480: { fixedWidth: '16.25rem', padding: { left: '1.375rem' }},
338
+ },
339
+ }).mount();
340
+
341
+ // Next slide on click
342
+ if (window.innerWidth > 992) {
343
+ reviewsSplide.on('click', function () {
344
+ reviewsSplide.go('+1');
345
+ });
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
+ });
361
+ }
362
+
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
+ });
395
+ });
396
+ }
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();
263
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);
430
+ });
431
+
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
+ });
264
461
  }
265
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
+ }
725
+
726
+
266
727
  // !!!!!!!!! Keep this Alpine init at the end !!!!!!!!!
267
728
  window.Webflow ||= [];
268
729
  window.Webflow.push(() => {
730
+
269
731
  console.log('The new code source is loaded!');
270
732
  initAlpine();
271
733
  lazyLoadVideos();
@@ -281,8 +743,8 @@ function customGsapEasing() {
281
743
  revealFooter();
282
744
  pageLoadAnimation();
283
745
  pageTransitionAnimation();
746
+ customCursorOnClick();
284
747
  if (window.innerWidth < 992) {
285
748
  disableScrollMenu();
286
749
  }
287
-
288
750
  });