-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
Only dispatch dragStart event if mouse is actually dragging #22
Comments
Hi Jeff (@Tscheffrey), Thank you for opening this issue! You have a good point 👍. Thinking about these event names, they are pretty unfortunate as you describe. Considering the current implementation and behaviour of
If you don't mind you can post a CodeSandbox example for other users to understand this issue better. 👉 SuggestionI agree with you that this needs attention. Maybe we should consider achieving something like this:
What do you think? Does this make sense? Best, |
Hey David (@davidjerleke), thank you for your quick reply. I'll make a CodeSandbox if I have some time today. I totally agree with what you suggested, as the SuggestionWe might want to add threshold which will hold back the |
Hello Jeff (@Tscheffrey), Thank you for the feedback and your ideas 👍. embla.on('dragStart', dragDistance => {
// Do something here
}) And then it's up to the user to implement the threshold logic: const myDragThreshold = 5
embla.on('dragStart', dragDistance => {
if (dragDistance > myDragThreshold) {
// Do something here
}
}) What do you think? Best, |
Hi David (@davidjerleke), I think this wouldn't work because as I understand, the The only way how this might work is to have another event that fires when dragging occurs, before the result is rendered to the screen, maybe called const myDragThreshold = 5
embla.on('dragging', e => {
if (e.dragDistance < myDragThreshold) {
e.preventDragging()
}
}) But I guess at this point, it might be easier to just have the drag threshold as a config parameter: const embla = EmblaCarousel(emblaNode, {
dragThreshold: 5,
...
}) Jeff |
Hi Jeff (@Tscheffrey), You're right. Of course, as you say
We will achieve both the Thanks! Kindly, |
Hi David (@davidjerleke),
That is great! I imagine that the I'll open up a ticket concerning the drag threshold configurability. Jeff |
Hello Jeff (@Tscheffrey), Thank you for your quick response. Cool, I hope I will have some free time to implement these features soon. Thanks for your patience. Meanwhile, you could do a workaround by checking how far the pointer has moved from
I completely agree and think this makes sense 👍. Thanks a lot for your ideas and taking time to discuss this. All the best, |
Hi David (@davidjerleke), thanks for your responses and building this awesome slider! If I had the necessary skills, I'd help you implementing these features...
Good idea, this would serve the purpose for now. Greetings, |
Hello Jeff (@Tscheffrey), I'm working on this issue and would appreciate feedback from you. The issue discussed above with
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 (it's also related to issue #24). This method is an opt-in feature and here is how it works: It returns Mouse Pointers
Touch Pointers
Otherwise it will return Kindly, |
I've taken the unfortunate naming into account and renamed the drag events to pointer events:
This has been implemented and released with version 3. |
It would be great if the dragStart event would not fire when the mouse goes down but rather when the cursor actually starts moving. Currently, dragStart and dragEnd will be fired if I only click/touch the slider without moving the cursor.
This would be useful to me because I am currently listening to both click events on items and dragStart/dragEnd Events and change styles accordingly. This leads to the item click having weird effects as it first transitions to the "drag" styles and back before the click event is fired.
I am currently using
embla-carousel-react
but I think this is something that concerns all variants of embla.Let me know if you need an example.
Great Work by the way! 😊
The text was updated successfully, but these errors were encountered: