react-fast-marquee
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -56,20 +56,15 @@ | ||
var _u = React.useState(0), marqueeWidth = _u[0], setMarqueeWidth = _u[1]; | ||
var _v = React.useState(0), duration = _v[0], setDuration = _v[1]; | ||
var _w = React.useState(false), isMounted = _w[0], setIsMounted = _w[1]; | ||
var _v = React.useState(false), isMounted = _v[0], setIsMounted = _v[1]; | ||
var containerRef = React.useRef(null); | ||
var marqueeRef = React.useRef(null); | ||
var calculateWidth = function () { | ||
// Find width of container and width of marquee | ||
if (marqueeRef.current && containerRef.current) { | ||
setContainerWidth(containerRef.current.getBoundingClientRect().width); | ||
setMarqueeWidth(marqueeRef.current.getBoundingClientRect().width); | ||
} | ||
if (marqueeWidth < containerWidth) { | ||
setDuration(containerWidth / speed); | ||
} | ||
else { | ||
setDuration(marqueeWidth / speed); | ||
} | ||
}; | ||
React.useEffect(function () { | ||
if (!isMounted) | ||
return; | ||
var calculateWidth = function () { | ||
// Find width of container and width of marquee | ||
if (marqueeRef.current && containerRef.current) { | ||
setContainerWidth(containerRef.current.getBoundingClientRect().width); | ||
setMarqueeWidth(marqueeRef.current.getBoundingClientRect().width); | ||
} | ||
}; | ||
calculateWidth(); | ||
@@ -81,3 +76,3 @@ // Rerender on window resize | ||
}; | ||
}); | ||
}, [isMounted]); | ||
React.useEffect(function () { | ||
@@ -88,2 +83,6 @@ setIsMounted(true); | ||
var rgbaGradientColor = "rgba(" + gradientColor[0] + ", " + gradientColor[1] + ", " + gradientColor[2]; | ||
// Animation duration | ||
var duration = marqueeWidth < containerWidth | ||
? containerWidth / speed | ||
: marqueeWidth / speed; | ||
return (React__default['default'].createElement(React.Fragment, null, !isMounted ? null : (React__default['default'].createElement("div", { ref: containerRef, style: __assign(__assign({}, style), (_b = {}, _b["--pause-on-hover"] = pauseOnHover ? "paused" : "running", _b["--pause-on-click"] = pauseOnClick ? "paused" : "running", _b)), className: className + " marquee-container" }, | ||
@@ -90,0 +89,0 @@ gradient && (React__default['default'].createElement("div", { style: (_c = {}, |
{ | ||
"name": "react-fast-marquee", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "A lightweight React component that utilizes the power of CSS animations to create silky smooth marquees.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26941
201