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

Listening to events in other elements #560

Open
dilonhenrique opened this issue Apr 18, 2024 · 5 comments
Open

Listening to events in other elements #560

dilonhenrique opened this issue Apr 18, 2024 · 5 comments
Labels
question Further information is requested

Comments

@dilonhenrique
Copy link

First of all, thanks for this fantastic lib! The only one that really fits most of my project's needs.

I've forked your repo and made some changes for my usecase (maybe PR in the future), but there's something confusing me: been trying to capture a mouse event in other elements (not a item nor a dropzone) while dragging and I can't.

My need:
My dropzone is inside a accordeon, so I wanted to open this accordeon if the user hover its header for a while. I was thinking in, while dragging, capture the mouseover (or mouseenter, dragover, etc) event and than made the logic in this listener.

The problem is that I cant capture any of these. When I listen for those events in window object, it's fine, but not in other elements. Tryed to comment all preventDefault and stopPropagation I found, but no success.

Would like to understand what's happening and maybe have a suggestion to accomplish this.

Thank you so much!

@isaacHagoel isaacHagoel added the question Further information is requested label Apr 19, 2024
@isaacHagoel
Copy link
Owner

Could it be because the mouse is already down and the cursor is over the dragged element?
The lib itself checks what the element is hovering over every x milliseconds by calculating bounding rects.
If you could make a simple REPL reproducing the issue, I'll have a quick look

@dilonhenrique
Copy link
Author

Thanks for your quick response!

Here's the REPL: https://svelte.dev/repl/ab152d93955343439d7c2568a953668b?version=4.2.15

I think your explanation make sense. I'll run some tests here, to figure out what to do...

@isaacHagoel
Copy link
Owner

Hi, sorry for the delay, I got a bit sick. Do you still need my help here or do you have new findings?

@dilonhenrique
Copy link
Author

Hey!

I have added pointer-events: none to my dragged element to pass events through. It worked, but seems more like a hack...

The biggest con to this, is that cursor reacts to whatever is below.

I could Track mouse move, but seemed too memory expensive. May I try this next week though. The help I would appreciate is any ideas for solution beside those.

Thank you.

@isaacHagoel
Copy link
Owner

isaacHagoel commented Apr 21, 2024 via email

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

No branches or pull requests

2 participants