Skip to content

Commit

Permalink
fix: video not playing on thumb click
Browse files Browse the repository at this point in the history
  • Loading branch information
zamitto committed May 12, 2024
1 parent 05c6c7c commit 4302639
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/renderer/src/pages/game-details/gallery-slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export function GallerySlider({ gameDetails }: GallerySliderProps) {
const [arrowShow, setArrowShow] = useState(false);

const showNextImage = () => {
if (currentVideoRef.current) {
currentVideoRef.current.pause()
}

setMediaIndex((index: number) => {
if (index === mediaCount - 1) return 0;

Expand All @@ -45,10 +41,6 @@ export function GallerySlider({ gameDetails }: GallerySliderProps) {
};

const showPrevImage = () => {
if (currentVideoRef.current) {
currentVideoRef.current.pause()
}

setMediaIndex((index: number) => {
if (index === 0) return mediaCount - 1;

Expand All @@ -61,6 +53,10 @@ export function GallerySlider({ gameDetails }: GallerySliderProps) {
}, [gameDetails]);

useEffect(() => {
if (currentVideoRef.current) {
currentVideoRef.current.pause()
}

if (hasMovies && mediaContainerRef.current) {
mediaContainerRef.current.childNodes.forEach((node, index) => {
if (index == mediaIndex && node instanceof HTMLVideoElement) {
Expand Down

0 comments on commit 4302639

Please sign in to comment.