From 738aa47547818ebf57dc4f00099386a5a22a86d5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 1 Feb 2024 01:08:21 +0100 Subject: Remove `position` from `overlay::Element` --- widget/src/scrollable.rs | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'widget/src/scrollable.rs') 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> { - 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::() - .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::().translation( + self.direction, + bounds, + content_bounds, + ); + + self.content.as_widget_mut().overlay( + &mut tree.children[0], + layout.children().next().unwrap(), + renderer, + translation - offset, + ) } } -- cgit