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

Catch click event on draggable element #511

Open
RatebHabbab opened this issue Sep 20, 2021 · 7 comments
Open

Catch click event on draggable element #511

RatebHabbab opened this issue Sep 20, 2021 · 7 comments

Comments

@RatebHabbab
Copy link

Like implementing draggable overriding click events defined on draggable element, Is there any way to keep the click event?

@zjffun
Copy link
Contributor

zjffun commented Sep 20, 2021

Draggable element can addEventListener https://codepen.io/1010543618/pen/VwWxwME .

If you want more detailed control, you can use it in combination with other libraries, for example Hammer.js .

@RatebHabbab
Copy link
Author

It's not working when using Draggable.Swappable

@zjffun
Copy link
Contributor

zjffun commented Sep 20, 2021

I tried Draggable.Swappable and it worked. Maybe you want to listen mousedown, it can be triggered as long as the mouse is pressed. https://codepen.io/1010543618/pen/VwWxwME

WX20210920-184153@2x

@RatebHabbab
Copy link
Author

I finally realized the difference, you are using version @1.0.0-beta.11 while I'm using @1.0.0-beta.12,
It's working fine on .11 but not working on .12

@RatebHabbab
Copy link
Author

I can't downgrade to .11 because I'm using the drag:stopped event that exist in .12 version

@zjffun
Copy link
Contributor

zjffun commented Sep 20, 2021

I reproduced this bug. It seems that because the mouseup is not triggered on the original element. The temporary solution I can think of is to determine whether to trigger the click when mouseup https://codepen.io/1010543618/pen/VwWxwME

@zjffun
Copy link
Contributor

zjffun commented Sep 20, 2021

The motivation of clone original element and hide it was described in #242

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants