From 09bd2c46c06eba72da40852d82a52e7353cc9e9b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 27 Oct 2019 01:24:08 +0200 Subject: Expose scrollable offset properly --- native/src/widget/scrollable.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/scrollable.rs b/native/src/widget/scrollable.rs index 4644282b..f411915b 100644 --- a/native/src/widget/scrollable.rs +++ b/native/src/widget/scrollable.rs @@ -56,12 +56,7 @@ where Event::Mouse(mouse::Event::WheelScrolled { delta_y, .. }) => { - // TODO: Configurable speed (?) - self.state.offset = (self.state.offset as i32 - - delta_y.round() as i32 * 15) - .max(0) - .min((content_bounds.height - bounds.height) as i32) - as u32; + self.state.scroll(delta_y, bounds, content_bounds); } _ => {} } @@ -70,7 +65,8 @@ where let cursor_position = if is_mouse_over { Point::new( cursor_position.x, - cursor_position.y + self.state.offset as f32, + cursor_position.y + + self.state.offset(bounds, content_bounds) as f32, ) } else { Point::new(cursor_position.x, -1.0) -- cgit