ios - Inertia scrolling algorithm frame independant - predict end position -


i have implemented scrolling algorithm doing following: when user release finger, save current speed, , then, every frame, apply following friction formula speed *= pow(friction, dt), friction value between 0 , 1 , dt time since last frame. stop updates when sufficiently close zero.

but, want know scroll end @ time finger released, because want adjust scroll end centered on item.

it's similar function scrollviewwillenddragging(scrollview:withvelocity:targetcontentoffset:) of uiscrollview

to summarize, looking formula translate initial speed total delta movement , reverse formula delta movement speed.

it seems velocity described formula

v = v0 * exp(- k * t) 

(to ensure, show speed moments 0, dt, 2dt, 3dt)

where v0 starting velocity, k friction coefficient (depending on friction) find distance, have integrate velocity (link)

s = integral[0..infinity] (v * dt) = v0 / k 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -