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