diff options
| author | 2023-07-12 10:13:15 +0200 | |
|---|---|---|
| committer | 2023-07-12 10:13:15 +0200 | |
| commit | ce23e08d0d921040d1e6fb693149e638d291bd16 (patch) | |
| tree | fefab10187a3ed790ac1ab66e3d2ef488ee8c3fb /widget/src/scrollable.rs | |
| parent | d07bac36ab528ea5c3f4a09bb0ae010ae1b5c6da (diff) | |
| download | iced-ce23e08d0d921040d1e6fb693149e638d291bd16.tar.gz iced-ce23e08d0d921040d1e6fb693149e638d291bd16.tar.bz2 iced-ce23e08d0d921040d1e6fb693149e638d291bd16.zip  | |
Remove unnecessary cursor unavailability logic in `scrollable`
Diffstat (limited to 'widget/src/scrollable.rs')
| -rw-r--r-- | widget/src/scrollable.rs | 34 | 
1 files changed, 12 insertions, 22 deletions
diff --git a/widget/src/scrollable.rs b/widget/src/scrollable.rs index 9a43a978..88746ac4 100644 --- a/widget/src/scrollable.rs +++ b/widget/src/scrollable.rs @@ -1476,20 +1476,14 @@ pub(super) mod internals {              grabbed_at: f32,              cursor_position: Point,          ) -> f32 { -            let pct = if cursor_position.x < 0.0 && cursor_position.y < 0.0 { -                // cursor position is unavailable! Set to either end or beginning of scrollbar depending -                // on where the thumb currently is in the track -                (self.scroller.bounds.y / self.total_bounds.height).round() -            } else { -                (cursor_position.y -                    - self.bounds.y -                    - self.scroller.bounds.height * grabbed_at) -                    / (self.bounds.height - self.scroller.bounds.height) -            }; +            let percentage = (cursor_position.y +                - self.bounds.y +                - self.scroller.bounds.height * grabbed_at) +                / (self.bounds.height - self.scroller.bounds.height);              match self.alignment { -                Alignment::Start => pct, -                Alignment::End => 1.0 - pct, +                Alignment::Start => percentage, +                Alignment::End => 1.0 - percentage,              }          } @@ -1499,18 +1493,14 @@ pub(super) mod internals {              grabbed_at: f32,              cursor_position: Point,          ) -> f32 { -            let pct = if cursor_position.x < 0.0 && cursor_position.y < 0.0 { -                (self.scroller.bounds.x / self.total_bounds.width).round() -            } else { -                (cursor_position.x -                    - self.bounds.x -                    - self.scroller.bounds.width * grabbed_at) -                    / (self.bounds.width - self.scroller.bounds.width) -            }; +            let percentage = (cursor_position.x +                - self.bounds.x +                - self.scroller.bounds.width * grabbed_at) +                / (self.bounds.width - self.scroller.bounds.width);              match self.alignment { -                Alignment::Start => pct, -                Alignment::End => 1.0 - pct, +                Alignment::Start => percentage, +                Alignment::End => 1.0 - percentage,              }          }      }  | 
