Unified · Split
| @@ -60,18 +60,16 @@ function useExpandedImageKeyboardShortcuts(input: { · 59 unmodified lines | ||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | function ExpandedImageDialogContent({ preview, onClose }: ExpandedImageDialogProps) { |
| 63 | − const [currentIndex, setCurrentIndex] = useState(preview.index); | |
| 63 | + const [indexOffset, setIndexOffset] = useState(0); | |
| 64 | 64 | const images = preview.images; |
| 65 | 65 | const canNavigate = images.length > 1; |
| 66 | + const currentIndex = canNavigate | |
| 67 | + ? (preview.index + indexOffset + images.length) % images.length | |
| 68 | + : preview.index; | |
| 66 | 69 | |
| 67 | 70 | const navigateImage = (direction: -1 | 1) => { |
| 68 | − setCurrentIndex((existingIndex) => { | |
| 69 | − if (!canNavigate) return existingIndex; | |
| 70 | − const safeExistingIndex = | |
| 71 | − existingIndex >= 0 && existingIndex < images.length ? existingIndex : preview.index; | |
| 72 | − const nextIndex = (safeExistingIndex + direction + images.length) % images.length; | |
| 73 | − return nextIndex === existingIndex ? existingIndex : nextIndex; | |
| 74 | − }); | |
| 71 | + if (!canNavigate) return; | |
| 72 | + setIndexOffset((existingOffset) => existingOffset + direction); | |
| 75 | 73 | }; |
| 76 | 74 | |
| 77 | 75 | useExpandedImageKeyboardShortcuts({ |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "hasReactScan": true, |
| 3 | − "summary": "Profiler commits: 3 total (1 mount, 2 update), last 1.30ms", | |
| 3 | + "summary": "Profiler commits: 3 total (1 mount, 2 update), last 1.20ms", | |
| 4 | 4 | "report": { |
| 5 | 5 | "reactScanReport": null, |
| 6 | 6 | "renderEvents": [] |
| 7 | 7 | } |
| 8 | −} | |
| 8 | +} | |
Binary file not shown.