@solid-primitives/spring: obtain velocity?
is there some way I can obtain the velocity of the spring?
xy: I want to detect if the popup is being dragged faster than x pixels, to then dismiss in a "flick" mode
8 Replies
https://github.com/solidjs-community/solid-primitives/blob/main/packages/spring/src/index.ts
Doesn't seem like it.
It only returns the signal with the current value.
You could copy the source code and adapt it accordingly.
GitHub
solid-primitives/packages/spring/src/index.ts at main · solidjs-com...
A library of high-quality primitives that extend SolidJS reactivity. - solidjs-community/solid-primitives
I guess you can always calculate it too outside the primitive (save time + previous value), but could be a cool addition to the primitive (wdyt @thetarnav ?)
you mean access to internals?
Uhu
yeah that sounds good
but it’s usually difficult to keep the api “slick” unfortunately
I had something in my mind, but doesn't work actually. Maybe just calculating it in userland is the cleanest.
Could do an option and then return
{ value, velocity }
Or attach it to the signal
is a bit esotericyeah that’s what I mean
also now you need to make velocity a separate signal
velocity could be
() => { value(); return velocity }