@digital-b2c/coreui-kit 0.29.2 → 0.29.4

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.cjs CHANGED
@@ -610,7 +610,7 @@ var BrandsStrip = ({
610
610
  }) => {
611
611
  const [show, setShow] = React73.useState(false);
612
612
  const [shouldAnimate, setShouldAnimate] = React73.useState(false);
613
- const { is } = useViewPort_default();
613
+ const { is, device } = useViewPort_default();
614
614
  const isTabletBelow = is("tablet", "below");
615
615
  const containerRef = React73.useRef(null);
616
616
  const marqueeRef = React73.useRef(null);
@@ -668,33 +668,42 @@ var BrandsStrip = ({
668
668
  };
669
669
  react.useGSAP(
670
670
  () => {
671
+ let frameId;
671
672
  const refreshCalculations = () => {
673
+ var _a;
672
674
  if (!marqueeRef.current || !containerRef.current || logos.length === 0) return;
673
675
  const items = gsap__default.default.utils.toArray(marqueeRef.current.children);
674
676
  if (items.length === 0) return;
677
+ (_a = timeline.current) == null ? void 0 : _a.kill();
678
+ timeline.current = null;
679
+ gsap__default.default.set(items, { x: 0, xPercent: 0 });
675
680
  const itemWidth = items[0].clientWidth;
676
- const calculatedTotalWidth = shouldAnimate ? itemWidth * items.length + 120 * (items.length - 1) / 2 : itemWidth * items.length + 120 * (items.length - 1);
677
681
  const containerWidth = containerRef.current.clientWidth;
678
682
  if (containerWidth === 0) {
679
- requestAnimationFrame(refreshCalculations);
683
+ frameId = requestAnimationFrame(refreshCalculations);
680
684
  return;
681
685
  }
682
- if (containerWidth < calculatedTotalWidth) {
683
- setShouldAnimate(true);
684
- const ctx = gsap__default.default.context(() => {
685
- const loop = horizontalLoop(items, {
686
- repeat: -1,
687
- speed: 1,
688
- paddingRight: 120
689
- });
690
- timeline.current = loop;
691
- }, containerRef);
692
- return () => ctx.revert();
686
+ const calculatedTotalWidth = itemWidth * logos.length + 120 * (logos.length - 1);
687
+ const needsAnimation = containerWidth < calculatedTotalWidth;
688
+ if (needsAnimation !== shouldAnimate) {
689
+ setShouldAnimate(needsAnimation);
690
+ return;
693
691
  }
692
+ timeline.current = needsAnimation ? horizontalLoop(items, {
693
+ repeat: -1,
694
+ speed: 1,
695
+ paddingRight: 120
696
+ }) : null;
694
697
  };
695
698
  refreshCalculations();
699
+ return () => {
700
+ var _a;
701
+ if (frameId) cancelAnimationFrame(frameId);
702
+ (_a = timeline.current) == null ? void 0 : _a.kill();
703
+ timeline.current = null;
704
+ };
696
705
  },
697
- { scope: containerRef, dependencies: [logos] }
706
+ { scope: containerRef, dependencies: [logos, device, shouldAnimate] }
698
707
  );
699
708
  const handleMouseEnter = () => {
700
709
  setShow(true);
@@ -712,7 +721,7 @@ var BrandsStrip = ({
712
721
  if (logos.length === 0) return [];
713
722
  if (!shouldAnimate) return [...logos];
714
723
  return [...logos, ...logos];
715
- }, [logos]);
724
+ }, [logos, shouldAnimate]);
716
725
  return /* @__PURE__ */ jsxRuntime.jsxs(
717
726
  "div",
718
727
  {
@@ -3016,6 +3025,7 @@ var ContactModule = ({
3016
3025
  href: cta.url,
3017
3026
  isExternal: cta.isExternal,
3018
3027
  variant: ctas.length === 1 || key % 2 === 1 ? "primary" : "secondary",
3028
+ logo: cta.logo,
3019
3029
  children: cta.label
3020
3030
  },
3021
3031
  key