diff options
Diffstat (limited to 'widget/src/scrollable.rs')
-rw-r--r-- | widget/src/scrollable.rs | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 6e48cd10..207b2539 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -385,25 +385,24 @@ where tree: &'b mut Tree, layout: Layout<'_>, renderer: &Renderer, + translation: Vector, ) -> Option<overlay::Element<'b, Message, Theme, Renderer>> { - self.content - .as_widget_mut() - .overlay( - &mut tree.children[0], - layout.children().next().unwrap(), - renderer, - ) - .map(|overlay| { - let bounds = layout.bounds(); - let content_layout = layout.children().next().unwrap(); - let content_bounds = content_layout.bounds(); - let translation = tree - .state - .downcast_ref::<State>() - .translation(self.direction, bounds, content_bounds); - - overlay.translate(Vector::new(-translation.x, -translation.y)) - }) + let bounds = layout.bounds(); + let content_layout = layout.children().next().unwrap(); + let content_bounds = content_layout.bounds(); + + let offset = tree.state.downcast_ref::<State>().translation( + self.direction, + bounds, + content_bounds, + ); + + self.content.as_widget_mut().overlay( + &mut tree.children[0], + layout.children().next().unwrap(), + renderer, + translation - offset, + ) } } |