Fix ratio calculation on resize in PaneGrid

This commit is contained in:
Héctor Ramón Jiménez 2020-03-14 09:36:20 +01:00
parent ec334bdd36
commit a373682fa4

View File

@ -131,19 +131,15 @@ impl<'a, Message, Renderer> PaneGrid<'a, Message, Renderer> {
let ratio = match axis {
Axis::Horizontal => {
let position =
cursor_position.y - bounds.y + rectangle.y;
cursor_position.y - bounds.y - rectangle.y;
(position / (rectangle.y + rectangle.height))
.max(0.1)
.min(0.9)
(position / rectangle.height).max(0.1).min(0.9)
}
Axis::Vertical => {
let position =
cursor_position.x - bounds.x + rectangle.x;
cursor_position.x - bounds.x - rectangle.x;
(position / (rectangle.x + rectangle.width))
.max(0.1)
.min(0.9)
(position / rectangle.width).max(0.1).min(0.9)
}
};