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

Prevent click event on child element when dragging #24

Closed
alexcoroza opened this issue Oct 3, 2019 · 11 comments
Closed

Prevent click event on child element when dragging #24

alexcoroza opened this issue Oct 3, 2019 · 11 comments
Labels
feature request New feature or request good first issue Good for newcomers resolved This issue is resolved

Comments

@alexcoroza
Copy link

I created a carousel and added my custom clickable elements inside. The problem is when I drag the carousel and then I mouseup, click event is triggered which is not the desired action.

@davidjerleke
Copy link
Owner

Hi Alex (@alexcoroza),

Thanks for taking time to open this issue. Would you mind forking this CodeSandbox to demonstrate the issue and what you want to achieve? It's much easier for me to troubleshoot and help you that way. Thank you for your patience.

Kindly,
David

@alexcoroza
Copy link
Author

alexcoroza commented Oct 4, 2019

Oooh, Didnt expect this, you responded so quick. Here is the example scenario:

Sample Code

When you drag to change slides and then you mouseup on top of a slide, the click event is triggered. Actually Im using this library in my angular app so the sample codes in sandbox is quite different(but they show the same problem).

I tried many javascript drag scroll carousel libraries they have all this kind of issue except for the ngx-drag-scroll(though its laggy). As of now I'm just showing an inivisible overlay whenever .on('scrolling') is called then hide it when finished, just to prevent the child element's click event

@davidjerleke
Copy link
Owner

Hello Alex (@alexcoroza),

Thank you for the sample code 👍. Just want to make sure that I understand you correctly before we start discussing how to solve this issue:

  1. Do you want to prevent the click event from triggering if dragging has occurred?
  2. Or do you actually want to prevent the click event from triggering if carousel is scrolling?

All the best,
David

@alexcoroza
Copy link
Author

Yes the question 1. I just want to prevent the click event only when dragging.

@davidjerleke davidjerleke added investigating Issue is being looked into and removed question labels Oct 4, 2019
@davidjerleke davidjerleke changed the title Prevent click event on child element when scrolling Prevent click event on child element when dragging Oct 6, 2019
@davidjerleke davidjerleke added feature request New feature or request upcoming A feature or bug fix is on its way for this issue and removed investigating Issue is being looked into labels Oct 8, 2019
@davidjerleke
Copy link
Owner

davidjerleke commented Nov 16, 2019

Hello Alex (@alexcoroza),
I'm happy to announce that I've released a click check for Embla 🎉:

embla.clickAllowed()

Please read about it in the release description. You can see it in action in this CodeSandbox. This method is an opt-in feature and here is how it works: It returns false if:

Mouse Pointers

  • Mouse drags the carousel.

Touch Pointers

  • Touch drags the carousel.
  • Carousel is in motion (i.e. is scrolling).

Otherwise it will return true. Try v2.6.1 for this feature. I'd very much appreciate your feedback on this and if it solves your issue. Thank you in advance!

Kindly,
David

@davidjerleke davidjerleke added awaiting response Issue is awaiting feedback good first issue Good for newcomers and removed upcoming A feature or bug fix is on its way for this issue labels Nov 16, 2019
@davidjerleke davidjerleke pinned this issue Nov 22, 2019
@davidjerleke davidjerleke unpinned this issue Nov 22, 2019
@davidjerleke
Copy link
Owner

Hi Alex (@alexcoroza),

I’m curious if you’ve had the chance to try this yet?

Kindly,
David

@davidjerleke
Copy link
Owner

Hello again Alex (@alexcoroza),
I'm closing this due to lack of response. Feel free to reopen this issue if you don't think it's resolved.

Thank you for your feature request!
David

@davidjerleke davidjerleke removed the awaiting response Issue is awaiting feedback label Nov 26, 2019
@davidjerleke davidjerleke added the resolved This issue is resolved label Jan 28, 2020
@mrcm2000
Copy link

mrcm2000 commented May 9, 2020

Hey @davidjerleke this is exactly what I need but I'm struggling to figure out how to implement it while using the react version. Any chance you could provide a bit of guidance?

Thanks so much for you hard work in this, it has the smoothest animations I've found for a carousel library!

@davidjerleke
Copy link
Owner

Hi @coopemor,

I would be happy to help. In order to do so I need additional details. Are you using React hooks or class based components?

Kindly,
David

@mrcm2000
Copy link

mrcm2000 commented May 10, 2020

Amazing! Thank you @davidjerleke I'm using hooks in my design.

@davidjerleke
Copy link
Owner

davidjerleke commented May 11, 2020

Hello @coopemor,

Your question is related to the Embla Carousel React, so I decided to create a new issue there. Just follow this link and we'll continue this conversation there.

Thanks!
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request good first issue Good for newcomers resolved This issue is resolved
Projects
None yet
Development

No branches or pull requests

3 participants