mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-06 02:00:46 +00:00
selection bubble fix
This commit is contained in:
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);
|
||||
|
||||
Reference in new issue
Block a user