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 --- wgpu/src/renderer/scrollable.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'wgpu/src/renderer') diff --git a/wgpu/src/renderer/scrollable.rs b/wgpu/src/renderer/scrollable.rs index 14ff9ff4..5b93a765 100644 --- a/wgpu/src/renderer/scrollable.rs +++ b/wgpu/src/renderer/scrollable.rs @@ -16,11 +16,10 @@ impl scrollable::Renderer for Renderer { let content = layout.children().next().unwrap(); let content_bounds = content.bounds(); + let offset = scrollable.state.offset(bounds, content_bounds); + let cursor_position = if bounds.contains(cursor_position) { - Point::new( - cursor_position.x, - cursor_position.y + scrollable.state.offset as f32, - ) + Point::new(cursor_position.x, cursor_position.y + offset as f32) } else { Point::new(cursor_position.x, -1.0) }; @@ -30,7 +29,7 @@ impl scrollable::Renderer for Renderer { let primitive = Primitive::Scrollable { bounds, - offset: scrollable.state.offset, + offset, content: Box::new(content), }; @@ -41,7 +40,7 @@ impl scrollable::Renderer for Renderer { { let ratio = bounds.height / content_bounds.height; let scrollbar_height = bounds.height * ratio; - let y_offset = scrollable.state.offset as f32 * ratio; + let y_offset = offset as f32 * ratio; let scrollbar = Primitive::Quad { bounds: Rectangle { -- cgit