remove setPaneClickDistance from store and update it declaritively

This commit is contained in:
peterkogo
2025-10-27 12:06:53 +01:00
parent 4f549b1095
commit f8c547d92f
17 changed files with 26 additions and 30 deletions
+2 -1
View File
@@ -9,7 +9,6 @@ export type PanZoomParams = {
domNode: Element;
minZoom: number;
maxZoom: number;
paneClickDistance: number;
viewport: Viewport;
translateExtent: CoordinateExtent;
onDraggingChange: OnDraggingChange;
@@ -43,6 +42,8 @@ export type PanZoomUpdateOptions = {
lib: string;
onTransformChange: OnTransformChange;
connectionInProgress: boolean;
paneClickDistance: number;
selectionOnDrag?: boolean;
};
export type PanZoomInstance = {
+7 -5
View File
@@ -37,7 +37,6 @@ export function XYPanZoom({
domNode,
minZoom,
maxZoom,
paneClickDistance,
translateExtent,
viewport,
onPanZoom,
@@ -55,10 +54,7 @@ export function XYPanZoom({
isPanScrolling: false,
};
const bbox = domNode.getBoundingClientRect();
const d3ZoomInstance = zoom()
.clickDistance(!isNumeric(paneClickDistance) || paneClickDistance < 0 ? 0 : paneClickDistance)
.scaleExtent([minZoom, maxZoom])
.translateExtent(translateExtent);
const d3ZoomInstance = zoom().scaleExtent([minZoom, maxZoom]).translateExtent(translateExtent);
const d3Selection = select(domNode).call(d3ZoomInstance);
setViewportConstrained(
@@ -109,6 +105,8 @@ export function XYPanZoom({
lib,
onTransformChange,
connectionInProgress,
paneClickDistance,
selectionOnDrag,
}: PanZoomUpdateOptions) {
if (userSelectionActive && !zoomPanValues.isZoomingOrPanning) {
destroy();
@@ -116,6 +114,10 @@ export function XYPanZoom({
const isPanOnScroll = panOnScroll && !zoomActivationKeyPressed && !userSelectionActive;
d3ZoomInstance.clickDistance(
selectionOnDrag ? Infinity : !isNumeric(paneClickDistance) || paneClickDistance < 0 ? 0 : paneClickDistance
);
const wheelHandler = isPanOnScroll
? createPanOnScrollHandler({
zoomPanValues,