Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Click events are fired when only registered for Pan #35

Open
GitMax42 opened this issue Oct 31, 2022 · 5 comments
Open

Click events are fired when only registered for Pan #35

GitMax42 opened this issue Oct 31, 2022 · 5 comments

Comments

@GitMax42
Copy link

GitMax42 commented Oct 31, 2022

When I register for Pan gestures, I also get click events from event PointerEvent. Seems that Tap events are fired, which I did not register in the options. Why is that, how can I disable it?

@biodiv
Copy link
Owner

biodiv commented Nov 1, 2022

The click-Event is not fired by contactjs, this is the native implementation of the Browser. We could add an option that disables native click events.

@TBG-FR
Copy link

TBG-FR commented Nov 3, 2023

I am also facing this issue. I followed the Horizontal Slide Example combined with the Pan & Scroll, targeting body element, and now my clicks aren't working (navigation, buttons, etc) on Desktop (for some reason, if I emulated mobile view, they work well 🤔 ). ContactJS should not catch these click events, as we did not register anything for it !

@biodiv
Copy link
Owner

biodiv commented Nov 3, 2023

You could try to attach PointerListener to the panElement instead of body . Or are you listening to contactjs events outside of the panElement ?

If I understand you correctly, you are facing the following issue:

  • PointerListener attached to body
  • contactjs events are registered to panElement
  • click events outside the panElement , e.g. in the navigation, are NOT being fired, although you would expect them to be fired.

@TBG-FR
Copy link

TBG-FR commented Nov 3, 2023

You could try to attach PointerListener to the panElement instead of body . Or are you listening to contactjs events outside of the panElement ?

If I understand you correctly, you are facing the following issue:

  • PointerListener attached to body
  • contactjs events are registered to panElement
  • click events outside the panElement , e.g. in the navigation, are NOT being fired, although you would expect them to be fired.

Thanks for the quick answer ! In fact my panElement is the body, I have the following code

  const targetElement = document.body;

  const panRecognizer = new Pan(targetElement,
  {
      supportedDirections : Directions.Horizontal
  });
  const pointerListener = new PointerListener(targetElement, {
      supportedGestures: [panRecognizer],
  });
  

It allows me to handle swipeleft and swiperight perfectly 👌 But any click on a child element of body is caught by ContactJS... (I verified this by adding bubble: false to the Pan options and then clicks were working again, but the swipe wasn't)

I'll see if I can find a workaround by using two elements, one for the PointerListener and one to register events, but I'm not sure that would do 🤐

@TBG-FR
Copy link

TBG-FR commented Nov 9, 2023

I slightly modified my code to aim on other sub elements rather than body, and I just reproduced the same behaviour. Nothing happens when I click on some <a onclick='console.log("AAA')>...</a> links I have inside these elements... If I remove ContactJS, it works well, if I add .addEventListener('tap', (event) => to this element I see the event... But I didn't register a tapRecognizer, only Pan ! (event with an empty PointerListener I get this behaviour !)

Is that expected ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants