How to detect button holding in solid js?
Does anyone know how to detect a button being holding for 2 seconds and are there any libraries or built-in functions for holding gesture?
3 Replies
use
onPointerDown
and onPointerUp
. In onPointerDown
start a timer that exectures what you want to happen after 2 seconds and store it's id in a variable outside the function. In onPointerUp
call clearTimeout
with the id passed inI'm gonna try this
I actually once made bunch of utilities for this, ported from a svelte project. I didn't publish them, but I had thought that #solid-primitives had something for this, but it doesn't