chore(xypanzoom): prevent default for pinch zoom on nowheel element #5074
This commit is contained in:
@@ -141,11 +141,20 @@ export function createPanOnScrollHandler({
|
|||||||
|
|
||||||
export function createZoomOnScrollHandler({ noWheelClassName, preventScrolling, d3ZoomHandler }: ZoomOnScrollParams) {
|
export function createZoomOnScrollHandler({ noWheelClassName, preventScrolling, d3ZoomHandler }: ZoomOnScrollParams) {
|
||||||
return function (this: Element, event: any, d: unknown) {
|
return function (this: Element, event: any, d: unknown) {
|
||||||
// we still want to enable pinch zooming even if preventScrolling is set to false
|
if (event.type === 'wheel') {
|
||||||
const preventZoom = !preventScrolling && event.type === 'wheel' && !event.ctrlKey;
|
const isPinch = event.ctrlKey;
|
||||||
|
// we still want to enable pinch zooming even if preventScrolling is set to false
|
||||||
|
const preventZoom = !preventScrolling && !isPinch;
|
||||||
|
const isNoWheel = isWrappedWithClass(event, noWheelClassName);
|
||||||
|
|
||||||
if (preventZoom || isWrappedWithClass(event, noWheelClassName)) {
|
// if user is pinch zooming above a nowheel element, we don't want the browser to zoom
|
||||||
return null;
|
if (isPinch && isNoWheel) {
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (preventZoom || isNoWheel) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user