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
REEEEE3mo 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
Дикий
Дикий3mo ago
I'm gonna try this
foolswisdom
foolswisdom3mo 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