Hi guys, question: do you know if there is a way to read/overwrite the final position of a draggable layer with momentum on DragEnd? Thanks!
Sorry I'm in Berlin for a few days so I might respond slowly.
So you want to "predict" where it will end? Right now you can't because it's being driven by real physics. So every step it calculates only the next based on position and acceleration. The reason it works this way is that it can respond to events (user touch, run into constraints).
In theory you could calculate everything upfront (assuming nothing changes) but that would cost a lot of performance and often be a waste.
I see, thanks :)
What's the intended result.
I would like to know in advance the final position of a draggable layer with momentum in order to change it and make it snap to a specific position.
You can achieve that in a few ways. Ping me the project and I can take a look and be more specific.
Fran. Might be useful to summarize your solution
Sure and thanks for the tips John :)
Basically, while listening to change Y: when the layer has reached certain point I just fire an animation with a spring curve that uses the current velocity of the layer as the velocity parameter. Something like this: