fix ImageZoom patch (#2181)
This commit is contained in:
parent
a501da692f
commit
7b96071643
2 changed files with 7 additions and 6 deletions
|
@ -123,14 +123,13 @@ export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSiz
|
||||||
waitFor(() => instance.state.readyState === "READY", () => {
|
waitFor(() => instance.state.readyState === "READY", () => {
|
||||||
const elem = document.getElementById(ELEMENT_ID) as HTMLDivElement;
|
const elem = document.getElementById(ELEMENT_ID) as HTMLDivElement;
|
||||||
element.current = elem;
|
element.current = elem;
|
||||||
elem.firstElementChild!.setAttribute("draggable", "false");
|
elem.querySelector("img,video")?.setAttribute("draggable", "false");
|
||||||
if (instance.props.animated) {
|
if (instance.props.animated) {
|
||||||
originalVideoElementRef.current = elem!.querySelector("video")!;
|
originalVideoElementRef.current = elem!.querySelector("video")!;
|
||||||
originalVideoElementRef.current.addEventListener("timeupdate", syncVideos);
|
originalVideoElementRef.current.addEventListener("timeupdate", syncVideos);
|
||||||
setReady(true);
|
|
||||||
} else {
|
|
||||||
setReady(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setReady(true);
|
||||||
});
|
});
|
||||||
document.addEventListener("keydown", onKeyDown);
|
document.addEventListener("keydown", onKeyDown);
|
||||||
document.addEventListener("keyup", onKeyUp);
|
document.addEventListener("keyup", onKeyUp);
|
||||||
|
@ -155,7 +154,9 @@ export const Magnifier: React.FC<MagnifierProps> = ({ instance, size: initialSiz
|
||||||
|
|
||||||
if (!ready) return null;
|
if (!ready) return null;
|
||||||
|
|
||||||
const box = element.current!.getBoundingClientRect();
|
const box = element.current?.getBoundingClientRect();
|
||||||
|
|
||||||
|
if (!box) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
|
@ -171,7 +171,7 @@ export default definePlugin({
|
||||||
find: "handleImageLoad=",
|
find: "handleImageLoad=",
|
||||||
replacement: [
|
replacement: [
|
||||||
{
|
{
|
||||||
match: /showThumbhashPlaceholder:\i,/,
|
match: /placeholderVersion:\i,/,
|
||||||
replace: "...$self.makeProps(this),$&"
|
replace: "...$self.makeProps(this),$&"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue