Skip to content

Swiper Element breaks touch events #6450

Closed
@Paso

Description

@Paso

Check that this is really a bug

  • I confirm

Reproduction link

https://codepen.io/Tattoo4861/pen/eYLvwjO

Bug description

When using Swiper Element all touch events on the page are broken. Swiper takes over touch and pointer events and re-emits a invalid touchStart event that is missing many expected attributes, such as TouchEvent.touches (see https://developer.mozilla.org/en-US/docs/Web/API/Element/touchstart_event).

In the reproduction codepen we listen to touchStart which should have a touches attribute. When loading swiper the event is missing touches (among other things). If one removes the swiper script-tag the event works as expected again.

The code that is responsible for this is:

  1. swiper.emit('touchStart', e);
  2. el[domMethod]('pointerdown', swiper.onTouchStart, { passive: false });

Swiper should

  1. not create events does not exist, such as touch-events from pointer-events
  2. if emitting a touchStart event make sure it is a valid TouchEvent

Expected Behavior

No response

Actual Behavior

No response

Swiper version

9

Platform/Target and Browser Versions

Win10+Chrome

Validations

  • Follow our Code of Conduct
  • Read the docs.
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
  • Make sure this is a Swiper issue and not a framework-specific issue

Would you like to open a PR for this bug?

  • I'm willing to open a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions