mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-19 11:27:02 -04:00
fix occasional errors in Dearrow & ImageZoom
This commit is contained in:
parent
c2f8837602
commit
5b35d7c644
2 changed files with 9 additions and 5 deletions
|
@ -67,15 +67,18 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
|
|||
}
|
||||
};
|
||||
const syncVideos = () => {
|
||||
currentVideoElementRef.current!.currentTime = originalVideoElementRef.current!.currentTime;
|
||||
if (currentVideoElementRef.current && originalVideoElementRef.current)
|
||||
currentVideoElementRef.current.currentTime = originalVideoElementRef.current.currentTime;
|
||||
};
|
||||
|
||||
const updateMousePosition = (e: MouseEvent) => {
|
||||
if (!element.current) return;
|
||||
|
||||
if (instance.state.mouseOver && instance.state.mouseDown) {
|
||||
const offset = size.current / 2;
|
||||
const pos = { x: e.pageX, y: e.pageY };
|
||||
const x = -((pos.x - element.current!.getBoundingClientRect().left) * zoom.current - offset);
|
||||
const y = -((pos.y - element.current!.getBoundingClientRect().top) * 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);
|
||||
setLensPosition({ x: e.x - offset, y: e.y - offset });
|
||||
setImagePosition({ x, y });
|
||||
setOpacity(1);
|
||||
|
@ -184,6 +187,7 @@ export const Magnifier = ErrorBoundary.wrap<MagnifierProps>(({ instance, size: i
|
|||
src={originalVideoElementRef.current?.src ?? instance.props.src}
|
||||
autoPlay
|
||||
loop
|
||||
muted
|
||||
/>
|
||||
) : (
|
||||
<img
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue