simplify previewzoomoverlay clicks
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect, useRef, useState } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { ArrowLeftIcon, ArrowRightIcon } from '../ui/icons';
|
import { ArrowLeftIcon, ArrowRightIcon } from '../ui/icons';
|
||||||
import usePointerTap from '../ui/usePointerTap';
|
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
@@ -18,8 +17,6 @@ const ensureDocumentRoot = () => {
|
|||||||
return document.body;
|
return document.body;
|
||||||
};
|
};
|
||||||
|
|
||||||
const CLICK_DELAY_MS = 240;
|
|
||||||
|
|
||||||
const PreviewZoomOverlay = ({
|
const PreviewZoomOverlay = ({
|
||||||
open = false,
|
open = false,
|
||||||
display = null,
|
display = null,
|
||||||
@@ -233,19 +230,9 @@ const PreviewZoomOverlay = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const pointerTapHandler = usePointerTap({
|
const handleImageClick = (event) => {
|
||||||
delay: CLICK_DELAY_MS,
|
|
||||||
onSingle: () => {
|
|
||||||
onClose();
|
|
||||||
},
|
|
||||||
onDouble: ({ clientX, clientY }) => {
|
|
||||||
toggleZoomAtPoint(clientX, clientY);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleImagePointerDown = (event) => {
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
pointerTapHandler(event);
|
toggleZoomAtPoint(event.clientX ?? 0, event.clientY ?? 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!renderBackdrop || !activeDisplay?.url || !portalTarget) {
|
if (!renderBackdrop || !activeDisplay?.url || !portalTarget) {
|
||||||
@@ -301,13 +288,13 @@ const PreviewZoomOverlay = ({
|
|||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={stageClassName}
|
className={stageClassName}
|
||||||
onClick={(event) => event.stopPropagation()}
|
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={containerClassName}
|
className={containerClassName}
|
||||||
ref={scrollRef}
|
ref={scrollRef}
|
||||||
tabIndex={-1}
|
tabIndex={-1}
|
||||||
|
onClick={(event) => event.stopPropagation()}
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
src={effectiveDisplay.url}
|
src={effectiveDisplay.url}
|
||||||
@@ -321,7 +308,7 @@ const PreviewZoomOverlay = ({
|
|||||||
height: event.currentTarget.naturalHeight || null,
|
height: event.currentTarget.naturalHeight || null,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onPointerDown={handleImagePointerDown}
|
onClick={handleImageClick}
|
||||||
style={imageStyle}
|
style={imageStyle}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user