Merge pull request #1940 from AustinMReppert/fix/scrollable-touch-input-stuck

Fix/scrollable touch input stuck
This commit is contained in:
Héctor Ramón 2024-01-31 19:03:26 +01:00 committed by GitHub
commit d9118aca75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 10 deletions

View file

@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Clippy docs keyword quoting. [#2091](https://github.com/iced-rs/iced/pull/2091)
- Clippy map transformations. [#2090](https://github.com/iced-rs/iced/pull/2090)
- Inline format args for ease of reading. [#2089](https://github.com/iced-rs/iced/pull/2089)
- Stuck scrolling in `Scrollable` with touch events. [#1940](https://github.com/iced-rs/iced/pull/1940)
Many thanks to...

View file

@ -525,7 +525,7 @@ pub fn update<Message>(
let (mouse_over_y_scrollbar, mouse_over_x_scrollbar) =
scrollbars.is_mouse_over(cursor);
let event_status = {
let mut event_status = {
let cursor = match cursor_over_scrollable {
Some(cursor_position)
if !(mouse_over_x_scrollbar || mouse_over_y_scrollbar) =>
@ -589,7 +589,7 @@ pub fn update<Message>(
notify_on_scroll(state, on_scroll, bounds, content_bounds, shell);
return event::Status::Captured;
event_status = event::Status::Captured;
}
Event::Touch(event)
if state.scroll_area_touched_at.is_some()
@ -635,7 +635,7 @@ pub fn update<Message>(
}
}
return event::Status::Captured;
event_status = event::Status::Captured;
}
_ => {}
}
@ -647,7 +647,7 @@ pub fn update<Message>(
| Event::Touch(touch::Event::FingerLost { .. }) => {
state.y_scroller_grabbed_at = None;
return event::Status::Captured;
event_status = event::Status::Captured;
}
Event::Mouse(mouse::Event::CursorMoved { .. })
| Event::Touch(touch::Event::FingerMoved { .. }) => {
@ -673,7 +673,7 @@ pub fn update<Message>(
shell,
);
return event::Status::Captured;
event_status = event::Status::Captured;
}
}
_ => {}
@ -709,7 +709,7 @@ pub fn update<Message>(
);
}
return event::Status::Captured;
event_status = event::Status::Captured;
}
_ => {}
}
@ -722,7 +722,7 @@ pub fn update<Message>(
| Event::Touch(touch::Event::FingerLost { .. }) => {
state.x_scroller_grabbed_at = None;
return event::Status::Captured;
event_status = event::Status::Captured;
}
Event::Mouse(mouse::Event::CursorMoved { .. })
| Event::Touch(touch::Event::FingerMoved { .. }) => {
@ -749,7 +749,7 @@ pub fn update<Message>(
);
}
return event::Status::Captured;
event_status = event::Status::Captured;
}
_ => {}
}
@ -783,14 +783,14 @@ pub fn update<Message>(
shell,
);
return event::Status::Captured;
event_status = event::Status::Captured;
}
}
_ => {}
}
}
event::Status::Ignored
event_status
}
/// Computes the current [`mouse::Interaction`] of a [`Scrollable`].