From 01cd7b0de6f0985a61f54ffc4bf1a748f7ad3c90 Mon Sep 17 00:00:00 2001 From: Luther Tchofo Safo Date: Thu, 26 Sep 2024 20:09:12 +0200 Subject: [PATCH] Trying to set noDistraction true and false via idle. --- .../carousel-part-cleaned/carousel.tsx | 100 +++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/app/(pages)/carousel-part-cleaned/carousel.tsx b/app/(pages)/carousel-part-cleaned/carousel.tsx index fbaf3c9..8e2f294 100644 --- a/app/(pages)/carousel-part-cleaned/carousel.tsx +++ b/app/(pages)/carousel-part-cleaned/carousel.tsx @@ -372,6 +372,13 @@ 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. + */ + + const obj = {}; + // to hide the mouse when idle const onIdle = () => { @@ -386,7 +393,7 @@ export default function Carousel({ timeout: 2_000, onIdle, onActive, - events: ["mousemove"], + events: ["mousemove", "touchstart"], }); // to track when all animations are still active @@ -494,6 +501,40 @@ 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; + } + })()} + + {/* no effect on the nodistractions=true scrollposition issue */} {/* {noDistracting === "false" && ( */}
{ // unnecessarily but we never know if (debouncedParamsingScrollPosition.isPending()) @@ -536,6 +578,7 @@ export default function Carousel({ {index + 1 < images.length && ( { if (debouncedParamsingScrollPosition.isPending()) return; setIndexPlusOne(index); @@ -674,13 +717,66 @@ function ChevronRightIcon() { ); } +function ArrowsPointingInIcon() { + return ( + + + + ); +} + +function ArrowsPointingOutIcon() { + return ( + + + + ); +} + +function PhotoIcon() { + return ( + + + + ); +} + function ChevronButton({ children, isLeft, + isCenter, handleClick, }: Readonly<{ children: React.ReactNode; isLeft: boolean; + isCenter: boolean; handleClick: MouseEventHandler; }>) { return ( @@ -693,7 +789,7 @@ function ChevronButton({ whileHover={{ opacity: 0.8 }} // whileTap here considers pressing Enter to be whileTap, even though I have it with preventDefault() via useKeypress whileTap={{ scale: 0.9, transition: {} }} - className={`absolute top-1/2 -mt-4 flex size-8 items-center justify-center rounded-full bg-white ${isLeft ? "left-3" : "right-3"}`} + className={`absolute ${isCenter ? "top-1/2" : "top-6"} -mt-4 flex size-8 items-center justify-center rounded-full bg-white ${isLeft ? "left-3" : "right-3"}`} onClick={handleClick} > {children}