diff options
author | 2024-02-01 01:08:21 +0100 | |
---|---|---|
committer | 2024-02-01 01:08:21 +0100 | |
commit | 738aa47547818ebf57dc4f00099386a5a22a86d5 (patch) | |
tree | 4f262c1bc4d9b55f030146ec2a6f9b6cc421a6c5 /widget/src/scrollable.rs | |
parent | 7bbe4502170be1942c4e61d222e14401f724aa42 (diff) | |
download | iced-738aa47547818ebf57dc4f00099386a5a22a86d5.tar.gz iced-738aa47547818ebf57dc4f00099386a5a22a86d5.tar.bz2 iced-738aa47547818ebf57dc4f00099386a5a22a86d5.zip |
Remove `position` from `overlay::Element`
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, + ) } } |