Add long tap support to unlock elements
This commit is contained in:
parent
eb3d0e30c0
commit
6341949403
2 changed files with 14 additions and 3 deletions
|
@ -15,6 +15,7 @@ const PanZoomPane = ({
|
|||
const wrapperRef = React.useRef(null);
|
||||
const stateRef = React.useRef({
|
||||
moving: false,
|
||||
pointers: new Set(),
|
||||
});
|
||||
|
||||
const onWheel = React.useCallback(
|
||||
|
@ -74,6 +75,7 @@ const PanZoomPane = ({
|
|||
metaKey,
|
||||
isPrimary,
|
||||
}) => {
|
||||
stateRef.current.pointers.add(pointerId);
|
||||
if (!isPrimary) {
|
||||
return;
|
||||
}
|
||||
|
@ -195,6 +197,7 @@ const PanZoomPane = ({
|
|||
|
||||
const onPointerUp = React.useCallback(
|
||||
(e) => {
|
||||
stateRef.current.pointers.delete(e.pointerId);
|
||||
if (!e.isPrimary) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -173,6 +173,16 @@ const Selector = ({ children, moveFirst }) => {
|
|||
}
|
||||
};
|
||||
|
||||
const onLongTap = React.useCallback(
|
||||
({ target }) => {
|
||||
const foundElement = insideClass(target, "item");
|
||||
if (foundElement) {
|
||||
setSelected([foundElement.id]);
|
||||
}
|
||||
},
|
||||
[setSelected]
|
||||
);
|
||||
|
||||
const onTap = React.useCallback(
|
||||
({ target }) => {
|
||||
if (
|
||||
|
@ -191,9 +201,7 @@ const Selector = ({ children, moveFirst }) => {
|
|||
onDrag={onDrag}
|
||||
onDragEnd={onDragEnd}
|
||||
onTap={onTap}
|
||||
onLongTap={() => {
|
||||
console.log("longtap");
|
||||
}}
|
||||
onLongTap={onLongTap}
|
||||
>
|
||||
<div ref={wrapperRef}>
|
||||
{selector.moving && <SelectorZone {...selector} />}
|
||||
|
|
Loading…
Reference in a new issue