This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Fran Pérez
Posted Apr 16 - Read on Facebook

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!


Fran Pérez


Koen Bok

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.

Fran Pérez

I see, thanks :)

John Anthony Evans

What's the intended result.

Fran Pérez

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.

John Anthony Evans

You can achieve that in a few ways. Ping me the project and I can take a look and be more specific.

John Anthony Evans

Fran. Might be useful to summarize your solution

Fran Pérez

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:

Read the entire post on Facebook