ImageZoom: fix patch and minor issue with lens

This commit is contained in:
prism 2026-01-23 20:21:34 +01:00 • committed by sadan4
parent 27ae269071
commit 2200aff800
2 changed files with 5 additions and 14 deletions

View file

@ -104,21 +104,19 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ 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<MagnifierProps>(({ 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);

View file

@ -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"
}
},