@digital-b2c/coreui-kit 0.29.2 → 0.29.3
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 +25 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -2
- package/dist/index.css.map +1 -1
- package/dist/index.mjs +25 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -12
package/dist/index.mjs
CHANGED
|
@@ -601,7 +601,7 @@ var BrandsStrip = ({
|
|
|
601
601
|
}) => {
|
|
602
602
|
const [show, setShow] = useState(false);
|
|
603
603
|
const [shouldAnimate, setShouldAnimate] = useState(false);
|
|
604
|
-
const { is } = useViewPort_default();
|
|
604
|
+
const { is, device } = useViewPort_default();
|
|
605
605
|
const isTabletBelow = is("tablet", "below");
|
|
606
606
|
const containerRef = useRef(null);
|
|
607
607
|
const marqueeRef = useRef(null);
|
|
@@ -659,33 +659,42 @@ var BrandsStrip = ({
|
|
|
659
659
|
};
|
|
660
660
|
useGSAP(
|
|
661
661
|
() => {
|
|
662
|
+
let frameId;
|
|
662
663
|
const refreshCalculations = () => {
|
|
664
|
+
var _a;
|
|
663
665
|
if (!marqueeRef.current || !containerRef.current || logos.length === 0) return;
|
|
664
666
|
const items = gsap.utils.toArray(marqueeRef.current.children);
|
|
665
667
|
if (items.length === 0) return;
|
|
668
|
+
(_a = timeline.current) == null ? void 0 : _a.kill();
|
|
669
|
+
timeline.current = null;
|
|
670
|
+
gsap.set(items, { x: 0, xPercent: 0 });
|
|
666
671
|
const itemWidth = items[0].clientWidth;
|
|
667
|
-
const calculatedTotalWidth = shouldAnimate ? itemWidth * items.length + 120 * (items.length - 1) / 2 : itemWidth * items.length + 120 * (items.length - 1);
|
|
668
672
|
const containerWidth = containerRef.current.clientWidth;
|
|
669
673
|
if (containerWidth === 0) {
|
|
670
|
-
requestAnimationFrame(refreshCalculations);
|
|
674
|
+
frameId = requestAnimationFrame(refreshCalculations);
|
|
671
675
|
return;
|
|
672
676
|
}
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
speed: 1,
|
|
679
|
-
paddingRight: 120
|
|
680
|
-
});
|
|
681
|
-
timeline.current = loop;
|
|
682
|
-
}, containerRef);
|
|
683
|
-
return () => ctx.revert();
|
|
677
|
+
const calculatedTotalWidth = itemWidth * logos.length + 120 * (logos.length - 1);
|
|
678
|
+
const needsAnimation = containerWidth < calculatedTotalWidth;
|
|
679
|
+
if (needsAnimation !== shouldAnimate) {
|
|
680
|
+
setShouldAnimate(needsAnimation);
|
|
681
|
+
return;
|
|
684
682
|
}
|
|
683
|
+
timeline.current = needsAnimation ? horizontalLoop(items, {
|
|
684
|
+
repeat: -1,
|
|
685
|
+
speed: 1,
|
|
686
|
+
paddingRight: 120
|
|
687
|
+
}) : null;
|
|
685
688
|
};
|
|
686
689
|
refreshCalculations();
|
|
690
|
+
return () => {
|
|
691
|
+
var _a;
|
|
692
|
+
if (frameId) cancelAnimationFrame(frameId);
|
|
693
|
+
(_a = timeline.current) == null ? void 0 : _a.kill();
|
|
694
|
+
timeline.current = null;
|
|
695
|
+
};
|
|
687
696
|
},
|
|
688
|
-
{ scope: containerRef, dependencies: [logos] }
|
|
697
|
+
{ scope: containerRef, dependencies: [logos, device, shouldAnimate] }
|
|
689
698
|
);
|
|
690
699
|
const handleMouseEnter = () => {
|
|
691
700
|
setShow(true);
|
|
@@ -703,7 +712,7 @@ var BrandsStrip = ({
|
|
|
703
712
|
if (logos.length === 0) return [];
|
|
704
713
|
if (!shouldAnimate) return [...logos];
|
|
705
714
|
return [...logos, ...logos];
|
|
706
|
-
}, [logos]);
|
|
715
|
+
}, [logos, shouldAnimate]);
|
|
707
716
|
return /* @__PURE__ */ jsxs(
|
|
708
717
|
"div",
|
|
709
718
|
{
|