Remove unnecessary cursor unavailability logic in scrollable
This commit is contained in:
parent
d07bac36ab
commit
ce23e08d0d
1 changed files with 12 additions and 22 deletions
|
|
@ -1476,20 +1476,14 @@ pub(super) mod internals {
|
||||||
grabbed_at: f32,
|
grabbed_at: f32,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
let pct = if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
|
let percentage = (cursor_position.y
|
||||||
// cursor position is unavailable! Set to either end or beginning of scrollbar depending
|
- self.bounds.y
|
||||||
// on where the thumb currently is in the track
|
- self.scroller.bounds.height * grabbed_at)
|
||||||
(self.scroller.bounds.y / self.total_bounds.height).round()
|
/ (self.bounds.height - self.scroller.bounds.height);
|
||||||
} else {
|
|
||||||
(cursor_position.y
|
|
||||||
- self.bounds.y
|
|
||||||
- self.scroller.bounds.height * grabbed_at)
|
|
||||||
/ (self.bounds.height - self.scroller.bounds.height)
|
|
||||||
};
|
|
||||||
|
|
||||||
match self.alignment {
|
match self.alignment {
|
||||||
Alignment::Start => pct,
|
Alignment::Start => percentage,
|
||||||
Alignment::End => 1.0 - pct,
|
Alignment::End => 1.0 - percentage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1499,18 +1493,14 @@ pub(super) mod internals {
|
||||||
grabbed_at: f32,
|
grabbed_at: f32,
|
||||||
cursor_position: Point,
|
cursor_position: Point,
|
||||||
) -> f32 {
|
) -> f32 {
|
||||||
let pct = if cursor_position.x < 0.0 && cursor_position.y < 0.0 {
|
let percentage = (cursor_position.x
|
||||||
(self.scroller.bounds.x / self.total_bounds.width).round()
|
- self.bounds.x
|
||||||
} else {
|
- self.scroller.bounds.width * grabbed_at)
|
||||||
(cursor_position.x
|
/ (self.bounds.width - self.scroller.bounds.width);
|
||||||
- self.bounds.x
|
|
||||||
- self.scroller.bounds.width * grabbed_at)
|
|
||||||
/ (self.bounds.width - self.scroller.bounds.width)
|
|
||||||
};
|
|
||||||
|
|
||||||
match self.alignment {
|
match self.alignment {
|
||||||
Alignment::Start => pct,
|
Alignment::Start => percentage,
|
||||||
Alignment::End => 1.0 - pct,
|
Alignment::End => 1.0 - percentage,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue