mirror of
https://github.com/mediacms-io/mediacms.git
synced 2024-11-22 00:03:28 +01:00
refactor
This commit is contained in:
parent
a4872e7ea0
commit
103eb01d7f
@ -51,6 +51,7 @@ export default function ImageViewer() {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isModalOpen) return;
|
||||
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
@ -59,10 +60,7 @@ export default function ImageViewer() {
|
||||
};
|
||||
}, [isModalOpen, slideshowItems]);
|
||||
|
||||
|
||||
const handleKeyDown = (event) => {
|
||||
if (!isModalOpen) return;
|
||||
|
||||
if (event.key === 'ArrowRight') {
|
||||
handleNext();
|
||||
} else if (event.key === 'ArrowLeft') {
|
||||
@ -78,9 +76,8 @@ export default function ImageViewer() {
|
||||
setCurrentIndex((prevIndex) => (prevIndex - 1 + slideshowItems.length) % slideshowItems.length);
|
||||
};
|
||||
|
||||
const handleDotClick = (index) => {
|
||||
setCurrentIndex(index);
|
||||
};
|
||||
const handleDotClick = (index) => setCurrentIndex(index);
|
||||
|
||||
const handleImageClick = (index) => {
|
||||
const mediaPageUrl = site.url + slideshowItems[index]?.url;
|
||||
window.location.href = mediaPageUrl;
|
||||
|
Loading…
Reference in New Issue
Block a user