diff --git a/src/plugins/imageZoom/components/Magnifier.tsx b/src/plugins/imageZoom/components/Magnifier.tsx index f69ab4b37..f80a9069c 100644 --- a/src/plugins/imageZoom/components/Magnifier.tsx +++ b/src/plugins/imageZoom/components/Magnifier.tsx @@ -104,21 +104,19 @@ export const Magnifier = ErrorBoundary.wrap(({ instance, size: i const onMouseUp = () => { setOpacity(0); - if (settings.store.saveZoomValues) { - settings.store.zoom = zoom.current; - settings.store.size = size.current; - } }; const onWheel = async (e: WheelEvent) => { if (instance.state.mouseOver && instance.state.mouseDown && !isShiftDown.current) { const val = zoom.current + ((e.deltaY / 100) * (settings.store.invertScroll ? -1 : 1)) * settings.store.zoomSpeed; zoom.current = val <= 1 ? 1 : val; + if (settings.store.saveZoomValues) settings.store.zoom = zoom.current; updateMousePosition(e); } if (instance.state.mouseOver && instance.state.mouseDown && isShiftDown.current) { const val = size.current + (e.deltaY * (settings.store.invertScroll ? -1 : 1)) * settings.store.zoomSpeed; size.current = val <= 50 ? 50 : val; + if (settings.store.saveZoomValues) settings.store.size = size.current; updateMousePosition(e); } }; @@ -152,13 +150,6 @@ export const Magnifier = ErrorBoundary.wrap(({ instance, size: i }; }, []); - useLayoutEffect(() => () => { - if (settings.store.saveZoomValues) { - settings.store.zoom = zoom.current; - settings.store.size = size.current; - } - }); - const imageSrc = useMemo(() => { try { const imageUrl = new URL(instance.props.src); diff --git a/src/plugins/imageZoom/index.tsx b/src/plugins/imageZoom/index.tsx index 3d25eda96..b8878dded 100644 --- a/src/plugins/imageZoom/index.tsx +++ b/src/plugins/imageZoom/index.tsx @@ -163,10 +163,10 @@ export default definePlugin({ patches: [ { - find: ".dimensionlessImage,", + find: "useFullWidth:!0,shouldLink:", replacement: [ { - match: /className:\i\.media,/, + match: /className:\i\.\$_,/, replace: `id:"${ELEMENT_ID}",$&` }, { @@ -179,7 +179,7 @@ export default definePlugin({ { find: '="FOCUS_SENSITIVE",', replacement: { - match: /(?<=\.hidden]:)\i/, + match: /(?<=\[\i\.\i]:)\i&&!\i&&"PINNED"!==\i/, replace: "false" } },