Skip to content

Ignored attempt to cancel a touchmove event with cancelable=false due to event.preventDefault() in passive or non-cancelable events #538

@sarfrajadstreaks

Description

@sarfrajadstreaks

When using the library on mobile or in Chrome DevTools (device emulation), the following warning appears in the console when trying to scroll or pinch the image:

**[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted**

This points to the event.preventDefault() call in this.onTouchPanning.

This occurs because preventDefault() is being called on a TouchEvent that is not cancelable — either because:

The event was generated in a passive listener, or
The browser is currently handling scroll/zoom behavior that can’t be prevented (e.g. one finger is outside the zoom area)

Suggested Fix:

To avoid this warning (and ensure safe behavior across platforms),event.preventDefault()should only be called on cancelable events.
Recommended change in all places where preventDefault() is used for touch handling:
if (event.cancelable) {
event.preventDefault();
}
This avoids unnecessary warnings and ensures better compatibility, especially on mobile browsers and with multi-touch gestures.

Attaching the Recording of the issue

Image

Please refer to implemetation for the issue

https://codesandbox.io/p/sandbox/y536wv

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions