prevent pinch zooming while making a new conection

This commit is contained in:
peterkogo
2025-08-25 19:12:33 +02:00
parent 04055c9625
commit d7a3172a60
6 changed files with 17 additions and 2 deletions

View File

@@ -42,6 +42,7 @@ export type PanZoomUpdateOptions = {
zoomActivationKeyPressed: boolean;
lib: string;
onTransformChange: OnTransformChange;
connectionInProgress: boolean;
};
export type PanZoomInstance = {

View File

@@ -108,6 +108,7 @@ export function XYPanZoom({
zoomActivationKeyPressed,
lib,
onTransformChange,
connectionInProgress,
}: PanZoomUpdateOptions) {
if (userSelectionActive && !zoomPanValues.isZoomingOrPanning) {
destroy();
@@ -178,6 +179,7 @@ export function XYPanZoom({
noPanClassName,
noWheelClassName,
lib,
connectionInProgress,
});
d3ZoomInstance.filter(filter);

View File

@@ -12,6 +12,7 @@ export type FilterParams = {
noWheelClassName: string;
noPanClassName: string;
lib: string;
connectionInProgress: boolean;
};
export function createFilter({
@@ -25,6 +26,7 @@ export function createFilter({
noWheelClassName,
noPanClassName,
lib,
connectionInProgress,
}: FilterParams) {
return (event: any): boolean => {
const zoomScroll = zoomActivationKeyPressed || zoomOnScroll;
@@ -48,6 +50,11 @@ export function createFilter({
return false;
}
// we want to disable pinch-zooming while making a connection
if (connectionInProgress) {
return false;
}
// if the target element is inside an element with the nowheel class, we prevent zooming
if (isWrappedWithClass(event, noWheelClassName) && event.type === 'wheel') {
return false;