remove setPaneClickDistance from store and update it declaritively
This commit is contained in:
@@ -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 = {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user