summaryrefslogtreecommitdiff
path: root/src/components/Geshem.tsx
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2025-11-14 13:25:32 +0100
committerYuval Adam <_@yuv.al>2025-11-14 13:25:32 +0100
commit2a1786e95f818039253091d96baffd8cc39a5009 (patch)
treed190d5c48cd90161d617f0d400b981f443dd4206 /src/components/Geshem.tsx
parent862a3f7545e2ee0fe8741bcabf5cd92207376fff (diff)
Revert "Fix slider jumps"HEADmaster
This reverts commit 862a3f7545e2ee0fe8741bcabf5cd92207376fff.
Diffstat (limited to 'src/components/Geshem.tsx')
-rw-r--r--src/components/Geshem.tsx15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/components/Geshem.tsx b/src/components/Geshem.tsx
index 30fb9fa..b235f6f 100644
--- a/src/components/Geshem.tsx
+++ b/src/components/Geshem.tsx
@@ -1,4 +1,4 @@
-import React, { useState, useEffect, useRef } from "react";
+import React, { useState, useEffect } from "react";
import { Map } from "./Map";
import { Slider } from "./Slider";
@@ -18,7 +18,6 @@ export function Geshem({ date }: GeshemProps) {
undefined
);
const [slider, setSlider] = useState(0);
- const isInitialLoad = useRef(true);
useEffect(() => {
const fetchImages = async () =>
@@ -61,18 +60,10 @@ export function Geshem({ date }: GeshemProps) {
if (images.length > 0) {
setSlider(prevSlider => {
const maxIndex = playback ? PLAYBACK_SLOTS : images.length - 1;
-
- // On initial load, set to the latest image (rightmost)
- if (isInitialLoad.current) {
- isInitialLoad.current = false;
+ // If this is the first load (slider is 0) or if slider is out of bounds, set to max
+ if (prevSlider === 0 || prevSlider > maxIndex) {
return maxIndex;
}
-
- // If slider is out of bounds (e.g., after image count changes), clamp it
- if (prevSlider > maxIndex) {
- return maxIndex;
- }
-
return prevSlider;
});
}