From 3b9343f8236a84a3508bacfbc7e950020706a82c Mon Sep 17 00:00:00 2001 From: Luther Tchofo Safo Date: Thu, 26 Sep 2024 21:28:18 +0200 Subject: [PATCH] Now with top buttons. --- .../carousel-part-cleaned/carousel.tsx | 199 ++++++++++-------- 1 file changed, 115 insertions(+), 84 deletions(-) diff --git a/app/(pages)/carousel-part-cleaned/carousel.tsx b/app/(pages)/carousel-part-cleaned/carousel.tsx index 8e2f294..1a167d1 100644 --- a/app/(pages)/carousel-part-cleaned/carousel.tsx +++ b/app/(pages)/carousel-part-cleaned/carousel.tsx @@ -372,28 +372,26 @@ export default function Carousel({ } }, [index, objectFitting, width, images]); - /* FLASH IDEA - There's also improvements on idleness which could be made here like hiding everything when idle in fact... 1. this could circumvene my current bug when noDistractions = true and it could handle controls on mobile at the same time. - To put it simply, it's no longer hiding this, hiding that... It's everything is hidden when idle as a start point. - */ + // to hide the top controls and mouse when idle - const obj = {}; - - // to hide the mouse when idle + const [topControlsVisible, setTopControlsVisible] = useState(true); + // a tiny bug here where the mouse remains when hovering on the top buttons const onIdle = () => { + setTopControlsVisible(false); document.getElementById(CAROUSEL)!.style.cursor = "none"; }; const onActive = () => { + setTopControlsVisible(true); document.getElementById(CAROUSEL)!.style.cursor = "auto"; }; useIdleTimer({ - timeout: 2_000, + timeout: 3_000, onIdle, onActive, - events: ["mousemove", "touchstart"], + events: ["mousemove", "mousedown", "touchstart"], }); // to track when all animations are still active @@ -501,39 +499,46 @@ export default function Carousel({ - { - // unnecessarily but we never know - if (debouncedParamsingScrollPosition.isPending()) return; - rotateNoDistracting("right"); - }} - > - - - { - if (debouncedParamsingScrollPosition.isPending()) return; - rotateObjectFitting("right"); - }} - > - {(() => { - switch (objectFitting) { - case "cover": - return ; - case "contain": - return ; - case "scroll": - if (isDefaultDirectory) return ; - else return ; - default: - return null; - } - })()} - +
+ { + // unnecessarily but we never know + if (debouncedParamsingScrollPosition.isPending()) return; + rotateNoDistracting("right"); + }} + > + {noDistracting === "true" ? ( + + ) : ( + + )} + + { + if (debouncedParamsingScrollPosition.isPending()) return; + rotateObjectFitting("right"); + }} + > + {(() => { + switch (objectFitting) { + case "cover": + return ; + case "contain": + return ; + case "scroll": + if (isDefaultDirectory) return ; + else return ; + default: + return null; + } + })()} + {/* https://medium.com/nerd-for-tech/a-case-to-switch-using-switch-statements-in-react-e83e01154f60 */} + +
{/* no effect on the nodistractions=true scrollposition issue */} {/* {noDistracting === "false" && ( */} @@ -541,13 +546,13 @@ export default function Carousel({ className={clsx( noDistracting !== "false" && noDistracting !== "chevronsonly" && - "invisible", + "hidden", )} > {index > 0 && ( <> - { @@ -558,25 +563,13 @@ export default function Carousel({ }} > - + )} - - {/* )} */} - - {/* no effect on the nodistractions=true scrollposition issue */} - {/* {noDistracting === "false" && ( */} -
{index + 1 < images.length && ( - { @@ -585,7 +578,7 @@ export default function Carousel({ }} > - + )}
@@ -599,7 +592,7 @@ export default function Carousel({ "absolute inset-x-0 bottom-6 flex h-14 justify-center overflow-x-hidden", noDistracting !== "false" && noDistracting !== "imagesonly" && - "invisible", + "hidden", )} > ; +}>) { + return ( + + {children} + + ); +} + function ChevronLeftIcon() { return ( ; -}>) { +function CubeTransparentIcon() { return ( - - {children} - + + + ); +} + +function CubeIcon() { + return ( + + + ); }