Damped scroll effect

Added in version 3.0.0.

This scroll effect is inspired by Flutter’s BouncingScrollPhysics, which mimics iOS-style scrolling behavior. Key features:

  1. Logarithmic resistance during overscroll drag (rubber band feel)

  2. Critically damped spring for bounce-back (no oscillation)

  3. Exponential friction for momentum scrolling

  4. Mathematically guaranteed stability

IMPLEMENTATION NOTES:

This is a clean-room implementation based on understanding the physics and algorithms used in Flutter and iOS, not a direct port of the code.

Mathematical formulas, physical laws, and algorithms are not subject to copyright. This implementation uses standard physics equations and mathematical transformations that are in the public domain.

Differences from the original DampedScrollEffect:

This implementation is different from the original DampedScrollEffect that was introduced in Kivy 1.7.0. The original DampedScrollEffect had a numerical instability issue. This implementation uses critical damping to ensure the effect is stable. Additionally the properties in the effect are different, and allow for more control over the effect.

class kivy.effects.dampedscroll.DampedScrollEffect(**kwargs)[source]

Bases: ScrollEffect

Flutter-inspired scroll effect with iOS-style rubber banding.

This implementation uses:

  1. Logarithmic resistance for overscroll (increasing resistance as you pull)

  2. Critically damped spring for bounce-back (no oscillation)

  3. Exponential friction for smooth momentum

See module documentation for more information.

min_overscroll

An overscroll less than this amount will be normalized to 0.

min_overscroll is a NumericProperty and defaults to .5.

rubber_band_coeff

Rubber band resistance coefficient. Higher values = less resistance.

Flutter/iOS typically use ~0.55. Lower values (0.3-0.4) feel stiffer, higher values (0.6-0.8) feel more elastic.

rubber_band_coeff is a NumericProperty and defaults to 0.55.

spring_mass

Mass for spring simulation (affects bounce-back speed).

spring_mass is a NumericProperty and defaults to 1.0.

spring_stiffness

Stiffness for spring simulation (affects bounce-back speed).

spring_stiffness is a NumericProperty and defaults to 100.0.

update_velocity(dt)[source]

(internal) Update the velocity according to the frametime and friction.