-
Hi, I did a custom drag that allow the user to scroll a list by dragging it.
The problem is that those event are not linked to Alpine so it doesn't work with reactivity I really want to avoid having pointermove constantly registered and having to check with a condition like
I tried to have a dynamically bind event like this
But the dynamicEvent only get call at load and doesn't react when isDragging change For now I use the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
You should be able to just do but yeah, there isn't a way to conditionally bind events. You might also want to consider having the Also, be aware that if you're using |
Beta Was this translation helpful? Give feedback.
You should be able to just do
this._pointerMoveEvent.bind(this)
so that the function can access the component state withthis
but yeah, there isn't a way to conditionally bind events. You might also want to consider having the
pointerup
event have{ once: true }
on it just so you don't have to actively remove it either. Just let it remove itself.Also, be aware that if you're using
pointerdown
overmousedown
to allow touch events, you will need to callelement.releasePointerCapture()
otherwise, the browser will take the touches for scrolling/panning/zooming (maybe after a delay like most things do to show the person "grabbed" the thing they are touching.