Skip to main content

rubber_band

Function rubber_band 

pub fn rubber_band(distance: f32, limit: f32) -> f32
Expand description

iOS-style overscroll resistance.

distance is how far past the end the input asks to go; the return is how far the surface is allowed to move. limit is the asymptote — the surface approaches it and never arrives.

L·d / (d + L) is the algebraic simplification of the form usually quoted for UIScrollView, (1 − 1/(d·c/D + 1))·D/c with L = D/c. Two properties matter, both visible here: slope at d = 0 is exactly 1 (the first pixel past the end tracks the finger, the edge is never a wall), and slope decays monotonically toward zero (resistance builds the whole way, always a little more give and never much).