fix occasional errors in Dearrow & ImageZoom

This commit is contained in:
Vendicated 2024-05-28 02:35:40 +02:00
parent c2f8837602
commit 5b35d7c644
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18
2 changed files with 9 additions and 5 deletions

View file

@ -182,8 +182,8 @@ export default definePlugin({
// add dearrow button // add dearrow button
{ {
match: /children:\[(?=null!=\i\?\i\.renderSuppressButton)/, match: /children:\[(?=null!=\i\?(\i)\.renderSuppressButton)/,
replace: "children:[$self.renderButton(this),", replace: "children:[$self.renderButton($1),",
predicate: () => !settings.store.hideButton predicate: () => !settings.store.hideButton
} }
] ]

View file

@ -67,15 +67,18 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
} }
}; };
const syncVideos = () => { const syncVideos = () => {
currentVideoElementRef.current!.currentTime = originalVideoElementRef.current!.currentTime; if (currentVideoElementRef.current && originalVideoElementRef.current)
currentVideoElementRef.current.currentTime = originalVideoElementRef.current.currentTime;
}; };
const updateMousePosition = (e: MouseEvent) => { const updateMousePosition = (e: MouseEvent) => {
if (!element.current) return;
if (instance.state.mouseOver && instance.state.mouseDown) { if (instance.state.mouseOver && instance.state.mouseDown) {
const offset = size.current / 2; const offset = size.current / 2;
const pos = { x: e.pageX, y: e.pageY }; const pos = { x: e.pageX, y: e.pageY };
const x = -((pos.x - element.current!.getBoundingClientRect().left) * zoom.current - offset); const x = -((pos.x - element.current.getBoundingClientRect().left) * zoom.current - offset);
const y = -((pos.y - element.current!.getBoundingClientRect().top) * zoom.current - offset); const y = -((pos.y - element.current.getBoundingClientRect().top) * zoom.current - offset);
setLensPosition({ x: e.x - offset, y: e.y - offset }); setLensPosition({ x: e.x - offset, y: e.y - offset });
setImagePosition({ x, y }); setImagePosition({ x, y });
setOpacity(1); setOpacity(1);
@ -184,6 +187,7 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
src={originalVideoElementRef.current?.src ?? instance.props.src} src={originalVideoElementRef.current?.src ?? instance.props.src}
autoPlay autoPlay
loop loop
muted
/> />
) : ( ) : (
<img <img