-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
feat(onClickOutside): adds ignoreDragging
option
#3833
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
base: main
Are you sure you want to change the base?
feat(onClickOutside): adds ignoreDragging
option
#3833
Conversation
…ndler to fire when a user is dragging outside target element
ignoreDrag
option
ignoreDrag
optionignoreDraging
option
ignoreDraging
optionignoreDragging
option
any news? |
@antfu What about this PR? |
const startDragListener = ({ x, y }: PointerEvent) => { | ||
stopDragListener = useEventListener(window, 'pointermove', (e) => { | ||
const dX = Math.abs(x - e.x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we should call useEventListener
inside a function.
This might lead to unexpected behaviour.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bobbybol can you please dont create the eventlistener inside the function. if we call this function multiple times, it will create a memory leak.
Hi @OrbisK I can go two ways with this:
B. Have a persistent listener (only attached if Let me know which route you prefer, and I will make it happen |
Why cant we just have the listener at setup level? (POC) useEventListener(window, 'pointermove', (e) => {
if(!isDragging.value) return
//...
}
startDragging = ()=>{isDragging.value = true} We only have one listener on the window. I think this should work, no? If we want to only add the listener when dragging i think we can use a reactive target like: const target = computed((()=>{
isDragging.value ? window : null
})
useEventListener(target, 'pointermove', (e) => {
//...
} with this useEventListener should do all the work for us |
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Additional context