gsap-react-marquee 0.1.7 → 0.1.8
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.js +70 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +70 -42
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -7902,9 +7902,9 @@ const coreAnimation = (elementsToAnimate, startX, tl, isReverse, draggableTrigge
|
|
|
7902
7902
|
|
|
7903
7903
|
gsap$4.registerPlugin(react.useGSAP, Observer, InertiaPlugin, Draggable);
|
|
7904
7904
|
const GSAPReactMarquee = require$$0.forwardRef((props, ref) => {
|
|
7905
|
-
const { children, className, dir = "left", loop = -1, paused = false, fill = false, followScrollDir = false, scrollSpeed = 2.5, gradient = false, gradientColor = null, } = props;
|
|
7906
|
-
const rootRef = require$$0.useRef(null)
|
|
7907
|
-
const containerRef = rootRef;
|
|
7905
|
+
const { children, className, dir = "left", loop = -1, paused = false, fill = false, followScrollDir = false, scrollSpeed = 2.5, gradient = false, gradientColor = null, pauseOnHover = false, } = props;
|
|
7906
|
+
const rootRef = require$$0.useRef(null);
|
|
7907
|
+
const containerRef = ref || rootRef;
|
|
7908
7908
|
const marqueeRef = require$$0.useRef(null);
|
|
7909
7909
|
const [marqueeDuplicates, setMarqueeDuplicates] = require$$0.useState(1);
|
|
7910
7910
|
const [effectivelyGradient, setEffectivelyGradient] = require$$0.useState(null);
|
|
@@ -7916,8 +7916,8 @@ const GSAPReactMarquee = require$$0.forwardRef((props, ref) => {
|
|
|
7916
7916
|
}, [gradient]);
|
|
7917
7917
|
const isVertical = dir === "up" || dir === "down";
|
|
7918
7918
|
const isReverse = dir === "down" || dir === "right";
|
|
7919
|
-
react.useGSAP(() => {
|
|
7920
|
-
if (!(marqueeRef === null || marqueeRef === void 0 ? void 0 : marqueeRef.current) || !containerRef.current)
|
|
7919
|
+
react.useGSAP((_, contextSafe) => {
|
|
7920
|
+
if (!(marqueeRef === null || marqueeRef === void 0 ? void 0 : marqueeRef.current) || !containerRef.current || !contextSafe)
|
|
7921
7921
|
return;
|
|
7922
7922
|
const containerMarquee = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current;
|
|
7923
7923
|
const marquees = gsap$4.utils.toArray(containerMarquee.querySelectorAll(".gsap-react-marquee"));
|
|
@@ -7940,6 +7940,7 @@ const GSAPReactMarquee = require$$0.forwardRef((props, ref) => {
|
|
|
7940
7940
|
const containerMarqueeWidth = containerMarquee.offsetWidth;
|
|
7941
7941
|
const marqueeChildrenWidth = marqueesChildren[0].offsetWidth;
|
|
7942
7942
|
const startX = marqueesChildren[0].offsetLeft;
|
|
7943
|
+
let obs = null;
|
|
7943
7944
|
// Clamp scrollSpeed to valid range (1.1 to 4.0)
|
|
7944
7945
|
const clampedScrollSpeed = Math.min(4, Math.max(1.1, scrollSpeed));
|
|
7945
7946
|
setMarqueeDuplicates(calculateDuplicates(marqueeChildrenWidth, containerMarqueeWidth, isVertical, props));
|
|
@@ -7966,45 +7967,72 @@ const GSAPReactMarquee = require$$0.forwardRef((props, ref) => {
|
|
|
7966
7967
|
* - Speed changes are smoothly animated with acceleration and deceleration phases
|
|
7967
7968
|
* - ScrollSpeed multiplier is applied and clamped to valid range
|
|
7968
7969
|
*/
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7992
|
-
|
|
7993
|
-
}
|
|
7994
|
-
|
|
7995
|
-
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8002
|
-
|
|
8003
|
-
},
|
|
8004
|
-
}
|
|
7970
|
+
if (followScrollDir) {
|
|
7971
|
+
obs = Observer.create({
|
|
7972
|
+
onChangeY(self) {
|
|
7973
|
+
let factor = clampedScrollSpeed * (isReverse ? -1 : 1);
|
|
7974
|
+
if (self.deltaY < 0) {
|
|
7975
|
+
factor *= -1;
|
|
7976
|
+
}
|
|
7977
|
+
/**
|
|
7978
|
+
* Create smooth speed transition animation
|
|
7979
|
+
*
|
|
7980
|
+
* Phase 1: Quick acceleration to new speed (0.2s)
|
|
7981
|
+
* - timeScale: Controls timeline playback speed (higher = faster)
|
|
7982
|
+
* - factor * clampedScrollSpeed: Initial speed boost for responsive feel
|
|
7983
|
+
* - overwrite: Cancels any previous speed animations
|
|
7984
|
+
*
|
|
7985
|
+
* Phase 2: Gradual deceleration to sustained speed (1s delay + 1s duration)
|
|
7986
|
+
* - factor / clampedScrollSpeed: Settle to a more moderate sustained speed
|
|
7987
|
+
* - "+=0.3": Wait 0.3 seconds before starting deceleration
|
|
7988
|
+
*/
|
|
7989
|
+
gsap$4
|
|
7990
|
+
.timeline({
|
|
7991
|
+
defaults: {
|
|
7992
|
+
ease: "none",
|
|
7993
|
+
},
|
|
7994
|
+
})
|
|
7995
|
+
.to(tl, {
|
|
7996
|
+
timeScale: factor * clampedScrollSpeed,
|
|
7997
|
+
duration: 0.2,
|
|
7998
|
+
overwrite: true,
|
|
7999
|
+
})
|
|
8000
|
+
.to(tl, {
|
|
8001
|
+
timeScale: factor / clampedScrollSpeed,
|
|
8002
|
+
duration: 1,
|
|
8003
|
+
}, "+=0.3");
|
|
8004
|
+
},
|
|
8005
|
+
});
|
|
8006
|
+
}
|
|
8007
|
+
const onMouseEnter = contextSafe(() => {
|
|
8008
|
+
tl.timeScale(0);
|
|
8009
|
+
});
|
|
8010
|
+
const onMouseLeave = contextSafe(() => {
|
|
8011
|
+
tl.timeScale(1);
|
|
8005
8012
|
});
|
|
8013
|
+
if (pauseOnHover) {
|
|
8014
|
+
containerMarquee.addEventListener("mouseenter", onMouseEnter);
|
|
8015
|
+
containerMarquee.addEventListener("mouseleave", onMouseLeave);
|
|
8016
|
+
}
|
|
8017
|
+
return () => {
|
|
8018
|
+
containerMarquee.removeEventListener("mouseenter", onMouseEnter);
|
|
8019
|
+
containerMarquee.removeEventListener("mouseleave", onMouseLeave);
|
|
8020
|
+
tl.kill();
|
|
8021
|
+
obs === null || obs === void 0 ? void 0 : obs.kill();
|
|
8022
|
+
};
|
|
8006
8023
|
}, {
|
|
8007
|
-
dependencies: [
|
|
8024
|
+
dependencies: [
|
|
8025
|
+
marqueeDuplicates,
|
|
8026
|
+
dir,
|
|
8027
|
+
loop,
|
|
8028
|
+
paused,
|
|
8029
|
+
fill,
|
|
8030
|
+
followScrollDir,
|
|
8031
|
+
scrollSpeed,
|
|
8032
|
+
gradient,
|
|
8033
|
+
gradientColor,
|
|
8034
|
+
pauseOnHover,
|
|
8035
|
+
],
|
|
8008
8036
|
});
|
|
8009
8037
|
const getGradientColor = () => {
|
|
8010
8038
|
// Priority order: explicit gradientColor > auto-detected > fallback
|