question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Only dispatch dragStart event if mouse is actually dragging

See original GitHub issue

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! 😊

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Tscheffreycommented, Nov 14, 2022

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…

Meanwhile, you could do a workaround this by checking how far the pointer has moved from pointerdown to pointerup, and if it’s more than let’s say 5px ignore any click events.

Good idea, this would serve the purpose for now.

Greetings, Jeff

0reactions
davidjerlekecommented, Jun 12, 2020

I’ve taken the unfortunate naming into account and renamed the drag events to pointer events:

  • dragStart --> pointerDown
  • dragEnd --> pointerUp

This has been implemented and released with version 3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Only dispatch dragStart event if mouse is actually dragging #22
It would be great if the dragStart event would not fire when the mouse goes down but rather when the cursor actually starts...
Read more >
Drag'n'Drop with mouse events - The Modern JavaScript Tutorial
Use event delegation to track drag start: a single event handler on document for mousedown . If elements are dragged to top/bottom window...
Read more >
Programmatically fire HTML5 dragstart after mousemove
I have a div that can be dragged using the HTML5 API, but I only want the drag to occur if the user...
Read more >
7.7 Drag and drop — HTML5 - W3C
To make an element draggable is simple: give the element a draggable attribute, and set an event listener for dragstart that stores the...
Read more >
Part 15 - Drag and Drop (Native and mouse drag ... - YouTube
How to work in Cypress with Drag and Drop(DnD)?1. ... Customized methods on JavaScript Drag and Drop Events fora. HTML N...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found