tweak: forward on-press events

This commit is contained in:
Sean Hagstrom 2024-03-26 09:45:17 +00:00 committed by Icaro Motta
parent 389a730eff
commit 85382bbc28
No known key found for this signature in database
GPG Key ID: 009557D9D014DF07
1 changed files with 2 additions and 2 deletions

View File

@ -14,11 +14,11 @@
[{:keys [on-press allow-multiple-presses? throttle-duration]} throttle-id]
(if allow-multiple-presses?
on-press
(fn []
(fn [event]
(let [id @throttle-id]
(when (and id (not (get @throttle id)))
(swap! throttle assoc id true)
(on-press)
(on-press event)
(js/setTimeout
#(swap! throttle dissoc id)
(or throttle-duration 500)))))))