-
Notifications
You must be signed in to change notification settings - Fork 38
Clickable slide: don't allow clit during "sliding" #70
Comments
Hello @kiuKisas. I got this exact same issue while using on:click on the carousel slides. This svelte-carousel is a wrapper for a vanilla js library called Siema. Sadly, Siema is no longer under development/maintenance by the author. I came up with a simple solution which I hope works for you too. Quick solution:1. Create a preciseClick.js file with the following code:
2. Then use on your carousel slides like this:
How it worksI created a Svelte action that listens to the mousedown and mouseup events over a certain element, i.e. a carousel slide. On mousedown it will set a boolean 'moved' flag to false and will store the x and y position of the event. On mouseup it will check if the cursor moved by a variable amount of pixels. If it did, the 'moved' flag is set to true, else it will remain false. This flag is then evaluated to decide whether an event should be emitted:
REPL demo: I might submit a pull request with a built-in implementation of this solution later although I'm not sure if this is part of the intended scope or responsibility of this svelte-carousel component. For the time being you could use this action. |
Hey, I have a slider made of
a
link. When I grab the slider to move it, it click on my slide when I release. It shouldn'tThe text was updated successfully, but these errors were encountered: