selection bubble fix

This commit is contained in:
BFlat committed 2024-02-23 12:44:11 +07:00
1 parent b81e872623
commit 82bf86aa0e
1 file changed
+1 -15
@@ -43,26 +43,12 @@ export default function SelectionBubbles({
if (bubblesRef.current) {
const { scrollLeft, scrollWidth, clientWidth } = bubblesRef.current;
const isAtEnd = scrollWidth - Math.round(scrollLeft + clientWidth) <= 1;
const isAtStart = scrollLeft <= 1; // Check if at the start
const isAtStart = scrollLeft <= 1;
setShowGradient(!isAtEnd);
setShowLeftGradient(!isAtStart);
}
};
const checkForOverflowContent = () => {
if (bubblesRef.current) {
const { scrollWidth, clientWidth } = bubblesRef.current;
const isOverflowing = scrollWidth > clientWidth;
setShowGradient(isOverflowing);
}
};
useEffect(() => {
checkForOverflowContent();
window.addEventListener("resize", checkForOverflowContent);
return () => window.removeEventListener("resize", checkForOverflowContent);
}, [options]);
useEffect(() => {
if (bubblesRef.current) {
bubblesRef.current.addEventListener("scroll", handleScroll);