mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-01-23 00:56:23 +01:00
Attempt to fix Safari's cut-off images bug
This commit is contained in:
parent
c61e9bb61c
commit
1a835c32ab
1 changed files with 15 additions and 0 deletions
|
@ -12,6 +12,8 @@ import Icon from './icon';
|
|||
import Link from './link';
|
||||
import { formatDuration } from './status';
|
||||
|
||||
const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent); // https://stackoverflow.com/a/23522755
|
||||
|
||||
/*
|
||||
Media type
|
||||
===
|
||||
|
@ -117,6 +119,19 @@ function Media({ media, to, showOriginal, autoAnimate, onClick = () => {} }) {
|
|||
if (isImage) {
|
||||
// Note: type: unknown might not have width/height
|
||||
quickPinchZoomProps.containerProps.style.display = 'inherit';
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (!isSafari) return;
|
||||
(async () => {
|
||||
try {
|
||||
await fetch(mediaURL, { cache: 'reload', mode: 'no-cors' });
|
||||
mediaRef.current.src = mediaURL;
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
})();
|
||||
}, [mediaURL]);
|
||||
|
||||
return (
|
||||
<Parent
|
||||
ref={parentRef}
|
||||
|
|
Loading…
Reference in a new issue