-
-
- );
-}
+ );
+ },
+);
diff --git a/src/components/ui/SliderWithScaling.tsx b/src/components/ui/SliderWithScaling.tsx
index c706032..e0e8533 100644
--- a/src/components/ui/SliderWithScaling.tsx
+++ b/src/components/ui/SliderWithScaling.tsx
@@ -36,6 +36,10 @@ export function SliderWithScaling
({
const sliderRef = useRef(null);
const itemRef = useRef(null);
+ const controlsRef = useRef<{ left: () => void; right: () => void }>({
+ left: () => {},
+ right: () => {},
+ });
const [order, dispatch] = useReducer(
(state: typeof slides, action: 'prev' | 'next') => {
@@ -70,20 +74,20 @@ export function SliderWithScaling({
setCurrentSliding(null);
});
};
- }, []);
+ }, [slide]);
function nextSlide() {
- // if (!transiting) {
- // }
- setCurrentSliding('next');
- dispatch('next');
+ if (!transiting) {
+ setCurrentSliding('next');
+ dispatch('next');
+ }
}
function prevSlide() {
- // if (!transiting) {
- // }
- setCurrentSliding('prev');
- dispatch('prev');
+ if (!transiting) {
+ setCurrentSliding('prev');
+ dispatch('prev');
+ }
}
useEffect(() => {
@@ -91,8 +95,8 @@ export function SliderWithScaling({
}, [baseoffset, order, slide]);
const handlers = useSwipeable({
- onSwipedLeft: nextSlide,
- onSwipedRight: prevSlide,
+ onSwipedLeft: () => controlsRef.current.right(),
+ onSwipedRight: () => controlsRef.current.left(),
trackMouse: true,
preventScrollOnSwipe: true,
touchEventOptions: { passive: false },
@@ -100,7 +104,7 @@ export function SliderWithScaling({
return (
-
+
({
className={
'absolute ' +
(controlsPosition === 'top'
- ? 'top-[75px]'
- : 'bottom-0 sm:self-end self-center')
+ ? 'top-[75px] sm:self-end'
+ : 'lg:bottom-32 bottom-0 sm:self-end self-center')
}
/>