fixed double tapping on touch devices circumvents zoomOnDoubleClick

This commit is contained in:
peterkogo
2024-03-19 12:07:09 +01:00
parent 24a63391fc
commit 543b85cd10
2 changed files with 10 additions and 5 deletions

View File

@@ -69,6 +69,7 @@ export function XYPanZoom({
);
const d3ZoomHandler = d3Selection.on('wheel.zoom')!;
const d3DblClickZoomHandler = d3Selection.on('dblclick.zoom')!;
d3ZoomInstance.wheelDelta(wheelDelta);
function setTransform(transform: ZoomTransform, options?: PanZoomTransformOptions) {
@@ -165,6 +166,15 @@ export function XYPanZoom({
lib,
});
d3ZoomInstance.filter(filter);
// We cannot add zoomOnDoubleClick to the filter above because
// if double tapping on touch screens circumvents the filter and
// dblclick.zoom is triggered on the selection directly
if (zoomOnDoubleClick) {
d3Selection.on('dblclick.zoom', d3DblClickZoomHandler);
} else {
d3Selection.on('dblclick.zoom', null);
}
}
function destroy() {

View File

@@ -48,11 +48,6 @@ export function createFilter({
return false;
}
// if zoom on double click is disabled, we prevent the double click event
if (!zoomOnDoubleClick && event.type === 'dblclick') {
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;