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
REEEEE
REEEEE9mo ago
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 in
Дикий
ДикийOP9mo ago
I'm gonna try this
foolswisdom
foolswisdom9mo ago
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
Want results from more Discord servers?
Add your server