|
|
@@ -2,7 +2,7 @@ import * as React from "react"; |
|
|
import {createRef, useEffect, useState} from "react"; |
|
|
import {createRef, useEffect, useState} from "react"; |
|
|
|
|
|
|
|
|
import "./photo-viewer.scss" |
|
|
import "./photo-viewer.scss" |
|
|
import {ArrowLeft, ArrowRight} from "@mui/icons-material"; |
|
|
|
|
|
|
|
|
import {ArrowLeft, ArrowRight, Close} from "@mui/icons-material"; |
|
|
import {useCurrentInstance} from "../../services/current-instance/use-current-instance"; |
|
|
import {useCurrentInstance} from "../../services/current-instance/use-current-instance"; |
|
|
|
|
|
|
|
|
export function PhotoViewer() { |
|
|
export function PhotoViewer() { |
|
|
@@ -36,6 +36,9 @@ export function PhotoViewer() { |
|
|
setSelectedPhotoIndex(selectedPhotoIndex + 1); |
|
|
setSelectedPhotoIndex(selectedPhotoIndex + 1); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
const handleClose = () => { |
|
|
|
|
|
setSelectedPhotoIndex(-1); |
|
|
|
|
|
} |
|
|
const handleKeyUp = (e) => { |
|
|
const handleKeyUp = (e) => { |
|
|
switch (e.code) { |
|
|
switch (e.code) { |
|
|
case "ArrowLeft": |
|
|
case "ArrowLeft": |
|
|
@@ -103,10 +106,11 @@ export function PhotoViewer() { |
|
|
{hasPrevious && <ArrowLeft/>} |
|
|
{hasPrevious && <ArrowLeft/>} |
|
|
</div> |
|
|
</div> |
|
|
<div id="photoSlider"> |
|
|
<div id="photoSlider"> |
|
|
{hasPrevious && <div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}> |
|
|
|
|
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`} |
|
|
|
|
|
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/> |
|
|
|
|
|
</div>} |
|
|
|
|
|
|
|
|
{hasPrevious && |
|
|
|
|
|
<div className="photo photo--placeholder photo--previous" style={previousPhotoStyle}> |
|
|
|
|
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex - 1].url}`} |
|
|
|
|
|
alt={selectedAlbum.photos[selectedPhotoIndex - 1].name}/> |
|
|
|
|
|
</div>} |
|
|
<div className="photo photo--invisible"> |
|
|
<div className="photo photo--invisible"> |
|
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex].url}`} |
|
|
<img src={`${selectedAlbum.photos[selectedPhotoIndex].url}`} |
|
|
alt={selectedAlbum.photos[selectedPhotoIndex].name}/> |
|
|
alt={selectedAlbum.photos[selectedPhotoIndex].name}/> |
|
|
@@ -123,6 +127,10 @@ export function PhotoViewer() { |
|
|
<div className="goto-btn goto-btn--next" onClick={handleGoNext}> |
|
|
<div className="goto-btn goto-btn--next" onClick={handleGoNext}> |
|
|
{hasNext && <ArrowRight/>} |
|
|
{hasNext && <ArrowRight/>} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div className="close-btn" onClick={handleClose}> |
|
|
|
|
|
{hasNext && <Close/>} |
|
|
|
|
|
</div> |
|
|
</div> : null} |
|
|
</div> : null} |
|
|
</> |
|
|
</> |
|
|
} |
|
|
} |