mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-24 02:46:43 +00:00
Don't scroll List on out-of-bounds mouse wheel events
This commit is contained in:
parent
188d727d31
commit
3fb1e6846d
1 changed files with 11 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::{
|
||||
px, AnyElement, AvailableSpace, BorrowAppContext, DispatchPhase, Element, IntoElement, Pixels,
|
||||
Point, ScrollWheelEvent, Size, Style, StyleRefinement, Styled, WindowContext,
|
||||
px, AnyElement, AvailableSpace, BorrowAppContext, BorrowWindow as _, DispatchPhase, Element,
|
||||
InteractiveBounds, IntoElement, Pixels, Point, ScrollWheelEvent, Size, Style, StyleRefinement,
|
||||
Styled, WindowContext,
|
||||
};
|
||||
use collections::VecDeque;
|
||||
use refineable::Refineable as _;
|
||||
|
@ -394,10 +395,17 @@ impl Element for List {
|
|||
state.items = new_items;
|
||||
state.last_layout_width = Some(bounds.size.width);
|
||||
|
||||
let interactive_bounds = Rc::new(InteractiveBounds {
|
||||
bounds: bounds.intersect(&cx.content_mask().bounds),
|
||||
stacking_order: cx.stacking_order().clone(),
|
||||
});
|
||||
|
||||
let list_state = self.state.clone();
|
||||
let height = bounds.size.height;
|
||||
cx.on_mouse_event(move |event: &ScrollWheelEvent, phase, cx| {
|
||||
if phase == DispatchPhase::Bubble {
|
||||
if interactive_bounds.visibly_contains(&event.position, cx)
|
||||
&& phase == DispatchPhase::Bubble
|
||||
{
|
||||
list_state.0.borrow_mut().scroll(
|
||||
&scroll_top,
|
||||
height,
|
||||
|
|
Loading…
Reference in a new issue