Jump to content
Search Community

onClick gets called on throwing draggable element

cbert test
Moderator Tag

Go to solution Solved by cbert,

Recommended Posts

Hi there,

 

I'm using Draggable with inertia true. The onClick event gets triggered every second time I drag an element (more than 3 pixels), which I thought it should not.

With inertia false, it works as expected -> onClick only gets fired if element has not moved more than 3 pixels.

 

Do you see if I do anything wrong here? The example here can't load inertia plugin, but you see my code:

https://svelte.dev/repl/c20bf7a911064883a0726c0946d92662?version=3.35.0

 

Thanks in advance and best regards,

 

Christian

 

PS: Does anyone know how to run svelte on CodePen?

 

 

Link to comment
Share on other sites

I believe I figured out what might be causing the issue you described, and it would only happen with type: "top,left" when the coordinates contain a decimal. It should be fixed in the next release which you can preview (compressed) at https://assets.codepen.io/16327/Draggable3.min.js

 

Does that work better for you? 

 

(and no, I don't know how to run svelte on CodePen, sorry)

  • Like 2
Link to comment
Share on other sites

Thanks for the quick response, that is truly amazing speed :-).

 

I tried to replace your file with the /node_modules/gsap/dist/Draggable.min.js and also then tried to replace the non-minified version.

Not sure if that's the way to do it, though?

 

Both lead to the same behaviour as before (meaning click event was fired).

I also tried to switch to x, y and as far as I can tell I had the same issue.

 

Please let me know if I can help with other testing scenarios!

 

Link to comment
Share on other sites

  • Solution

I think I found the issue. My implementation triggered Draggable.create multiple times which lead to this behaviour (basically click event was fired multiple times due to this). But thanks for the quick response!

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...