diff --git a/src/lib.rs b/src/lib.rs index 8dceba3..5b0b4bd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,7 @@ impl Plugin for ScrollViewPlugin { input_mouse_pressed_move, input_touch_pressed_move, scroll_events, + fling_update, scroll_update, ) .chain(), @@ -44,12 +45,18 @@ pub struct ScrollView { /// Field which control speed of the scrolling. /// Could be negative number to implement invert scroll pub scroll_speed: f32, + /// Amount of friction to apply to slow down the fling + pub friction: f32, + /// Current vertical velocity + pub velocity: f32, } impl Default for ScrollView { fn default() -> Self { Self { scroll_speed: 1200.0, + friction: 4.2, + velocity: 0.0, } } } @@ -174,24 +181,19 @@ fn update_size( fn input_touch_pressed_move( touches: Res, - mut q: Query<(&Children, &Interaction), With>, - mut content_q: Query<&mut ScrollableContent>, + mut q: Query<(&Interaction, &mut ScrollView)>, + time: Res