mirror of https://github.com/wayvr-org/wayvr.git
wgui: bugfix: scrollable list could start swipe event out-of-bounds (Closes #586)
This commit is contained in:
parent
629de4c8ff
commit
8adff4ca6a
|
|
@ -88,7 +88,7 @@ pub enum Event {
|
|||
}
|
||||
|
||||
impl Event {
|
||||
fn test_transform_pos(transform: &Transform, pos: Vec2) -> bool {
|
||||
pub fn test_transform_pos(transform: &Transform, pos: Vec2) -> bool {
|
||||
pos.x >= transform.abs_pos.x
|
||||
&& pos.x < transform.abs_pos.x + transform.visual_dim.x
|
||||
&& pos.y >= transform.abs_pos.y
|
||||
|
|
|
|||
|
|
@ -613,16 +613,25 @@ impl WidgetState {
|
|||
}
|
||||
|
||||
fn process_swipe_event(&mut self, event: &Event, params: &EventParams) {
|
||||
let Event::MouseDown(e) = &event else {
|
||||
let Event::MouseDown(evt) = &event else {
|
||||
return;
|
||||
};
|
||||
|
||||
// firstly, check if this widget is scrollable at all
|
||||
let (active_x, active_y) = get_scroll_active_axis(params.style, params.taffy_layout);
|
||||
if active_x || active_y {
|
||||
self.data.press_down_start_mouse_pos = Some(e.pos);
|
||||
self.data.swipe_scroll_start = self.data.scrolling_target;
|
||||
if !active_x && !active_y {
|
||||
return;
|
||||
}
|
||||
|
||||
// check if the mouse hovers over *parent* boundaries
|
||||
// we assume there that our parent is non-scrollable
|
||||
let transform_parent = params.alterables.transform_stack.parent();
|
||||
if !Event::test_transform_pos(transform_parent, evt.pos) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.data.press_down_start_mouse_pos = Some(evt.pos);
|
||||
self.data.swipe_scroll_start = self.data.scrolling_target;
|
||||
}
|
||||
|
||||
pub fn process_event<'a, 'b, U1: 'static, U2: 'static>(
|
||||
|
|
|
|||
Loading…
Reference in New Issue