Skip to content

Commit

Permalink
Fix clip bounds with nested scrollable widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Apr 23, 2024
1 parent 15e1570 commit 67e181c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ where
let content_layout = layout.children().next().unwrap();
let content_bounds = content_layout.bounds();

let Some(visible_bounds) = bounds.intersection(viewport) else {
return;
};

let scrollbars =
Scrollbars::new(state, self.direction, bounds, content_bounds);

Expand Down Expand Up @@ -704,7 +708,7 @@ where

// Draw inner content
if scrollbars.active() {
renderer.with_layer(bounds, |renderer| {
renderer.with_layer(visible_bounds, |renderer| {
renderer.with_translation(
Vector::new(-translation.x, -translation.y),
|renderer| {
Expand Down Expand Up @@ -767,9 +771,9 @@ where

renderer.with_layer(
Rectangle {
width: (bounds.width + 2.0).min(viewport.width),
height: (bounds.height + 2.0).min(viewport.height),
..bounds
width: (visible_bounds.width + 2.0).min(viewport.width),
height: (visible_bounds.height + 2.0).min(viewport.height),
..visible_bounds
},
|renderer| {
if let Some(scrollbar) = scrollbars.y {
Expand Down

0 comments on commit 67e181c

Please sign in to comment.