From 92786450693668910b24ca3a2efe36e3db86362b Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Mon, 26 Dec 2022 01:09:19 +0800 Subject: [PATCH] Another attempt at fixing GIF not autoplaying on Mobile Safari --- src/components/status.css | 1 + src/components/status.jsx | 21 +++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/components/status.css b/src/components/status.css index 69854ba4..a5b3e8b4 100644 --- a/src/components/status.css +++ b/src/components/status.css @@ -374,6 +374,7 @@ } .status .media-gif video { object-fit: cover; + pointer-events: none; } .status .media-audio { border: 0; diff --git a/src/components/status.jsx b/src/components/status.jsx index 7088168e..7651f03e 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -755,14 +755,19 @@ function Media({ media, showOriginal, onClick = () => {} }) { rgbAverageColor && `rgb(${rgbAverageColor.join(',')})`, }} onClick={(e) => { - if (showOriginal && isGIF) { - try { - if (videoRef.current.paused) { - videoRef.current.play(); - } else { - videoRef.current.pause(); - } - } catch (e) {} + if (isGIF) { + // Hmm, the videoRef might conflict here + if (showOriginal) { + try { + if (videoRef.current.paused) { + videoRef.current.play(); + } else { + videoRef.current.pause(); + } + } catch (e) {} + } else { + videoRef.current.pause(); + } } onClick(e); }}