fix pan through table
This commit is contained in:
@@ -97,7 +97,7 @@ function GroupNode({ id, data }) {
|
|||||||
className="node-resize-handle"
|
className="node-resize-handle"
|
||||||
minWidth={groupMinSize.width}
|
minWidth={groupMinSize.width}
|
||||||
minHeight={groupMinSize.height}
|
minHeight={groupMinSize.height}
|
||||||
onResizeEnd={(event, params) => ctx.onResizeGroup?.(id, params)}
|
onResizeEnd={(_event, params) => ctx.onResizeGroup?.(id, params)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={`custom-node group-node ${collapsed ? 'group-node-collapsed' : 'group-node-expanded'}`}>
|
<div className={`custom-node group-node ${collapsed ? 'group-node-collapsed' : 'group-node-expanded'}`}>
|
||||||
@@ -788,13 +788,46 @@ function ColorMapStopsEditor({ nodeId, name, value, onChange }) {
|
|||||||
function NodeTable({ rows }) {
|
function NodeTable({ rows }) {
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const scrollRef = useRef(null);
|
const scrollRef = useRef(null);
|
||||||
|
const isInsideRef = useRef(false);
|
||||||
|
const pointerEnteredAtRef = useRef(0);
|
||||||
|
const lastWheelAtRef = useRef(0);
|
||||||
|
const gestureStartedInsideRef = useRef(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const el = scrollRef.current;
|
const el = scrollRef.current;
|
||||||
if (!el) return;
|
if (!el) return;
|
||||||
const handler = (e) => e.stopPropagation();
|
|
||||||
el.addEventListener('wheel', handler, { passive: false });
|
const onEnter = () => {
|
||||||
return () => el.removeEventListener('wheel', handler);
|
isInsideRef.current = true;
|
||||||
|
pointerEnteredAtRef.current = Date.now();
|
||||||
|
};
|
||||||
|
const onLeave = () => {
|
||||||
|
isInsideRef.current = false;
|
||||||
|
};
|
||||||
|
const onWheel = (e) => {
|
||||||
|
const now = Date.now();
|
||||||
|
const msSinceLastWheel = now - lastWheelAtRef.current;
|
||||||
|
const msSinceEnter = now - pointerEnteredAtRef.current;
|
||||||
|
lastWheelAtRef.current = now;
|
||||||
|
|
||||||
|
if (msSinceLastWheel > 300) {
|
||||||
|
// First event of a new gesture — only capture if pointer was already settled inside
|
||||||
|
gestureStartedInsideRef.current = isInsideRef.current && msSinceEnter > 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gestureStartedInsideRef.current) {
|
||||||
|
e.stopPropagation();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
el.addEventListener('wheel', onWheel, { passive: false });
|
||||||
|
el.addEventListener('pointerenter', onEnter);
|
||||||
|
el.addEventListener('pointerleave', onLeave);
|
||||||
|
return () => {
|
||||||
|
el.removeEventListener('wheel', onWheel);
|
||||||
|
el.removeEventListener('pointerenter', onEnter);
|
||||||
|
el.removeEventListener('pointerleave', onLeave);
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const columns = getTableColumns(rows);
|
const columns = getTableColumns(rows);
|
||||||
|
|||||||
Reference in New Issue
Block a user