Respect a div's own z-index when adding its event listeners
This commit is contained in:
parent
ee8e1454fc
commit
b88370d5ad
2 changed files with 539 additions and 540 deletions
|
@ -778,9 +778,6 @@ impl Element for Div {
|
|||
&mut element_state.interactive_state,
|
||||
cx,
|
||||
|style, scroll_offset, cx| {
|
||||
let z_index = style.z_index.unwrap_or(0);
|
||||
|
||||
cx.with_z_index(z_index, |cx| {
|
||||
style.paint(bounds, cx, |cx| {
|
||||
cx.with_text_style(style.text_style().cloned(), |cx| {
|
||||
cx.with_content_mask(style.overflow_mask(bounds), |cx| {
|
||||
|
@ -791,7 +788,6 @@ impl Element for Div {
|
|||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
|
@ -918,6 +914,8 @@ impl Interactivity {
|
|||
return;
|
||||
}
|
||||
|
||||
let z_index = style.z_index.unwrap_or(0);
|
||||
cx.with_z_index(z_index, |cx| {
|
||||
#[cfg(debug_assertions)]
|
||||
if self.element_id.is_some()
|
||||
&& (style.debug || style.debug_below || cx.has_global::<crate::DebugBelow>())
|
||||
|
@ -1034,7 +1032,7 @@ impl Interactivity {
|
|||
.as_ref()
|
||||
.is_some_and(|fill| fill.color().is_some_and(|color| !color.is_transparent()))
|
||||
{
|
||||
cx.with_z_index(style.z_index.unwrap_or(0), |cx| cx.add_opaque_layer(bounds))
|
||||
cx.add_opaque_layer(bounds)
|
||||
}
|
||||
|
||||
let interactive_bounds = InteractiveBounds {
|
||||
|
@ -1189,13 +1187,15 @@ impl Interactivity {
|
|||
let pending_mouse_down = pending_mouse_down.clone();
|
||||
move |event: &MouseMoveEvent, phase, cx| {
|
||||
let mut pending_mouse_down = pending_mouse_down.borrow_mut();
|
||||
|
||||
if let Some(mouse_down) = pending_mouse_down.clone() {
|
||||
if cx.active_drag.is_some() {
|
||||
if phase == DispatchPhase::Capture {
|
||||
cx.notify();
|
||||
}
|
||||
} else if phase == DispatchPhase::Bubble
|
||||
&& (event.position - mouse_down.position).magnitude() > DRAG_THRESHOLD
|
||||
&& (event.position - mouse_down.position).magnitude()
|
||||
> DRAG_THRESHOLD
|
||||
{
|
||||
if let Some((drag_value, drag_listener)) = drag_listener.take() {
|
||||
*active_state.borrow_mut() = ElementClickedState::default();
|
||||
|
@ -1364,8 +1364,8 @@ impl Interactivity {
|
|||
let interactive_bounds = interactive_bounds.clone();
|
||||
cx.on_mouse_event(move |down: &MouseDownEvent, phase, cx| {
|
||||
if phase == DispatchPhase::Bubble && !cx.default_prevented() {
|
||||
let group =
|
||||
active_group_bounds.map_or(false, |bounds| bounds.contains(&down.position));
|
||||
let group = active_group_bounds
|
||||
.map_or(false, |bounds| bounds.contains(&down.position));
|
||||
let element = interactive_bounds.visibly_contains(&down.position, cx);
|
||||
if group || element {
|
||||
*active_state.borrow_mut() = ElementClickedState { group, element };
|
||||
|
@ -1454,6 +1454,7 @@ impl Interactivity {
|
|||
if let Some(group) = self.group.as_ref() {
|
||||
GroupBounds::pop(group, cx);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
pub fn compute_style(
|
||||
|
|
|
@ -200,7 +200,6 @@ impl Element for UniformList {
|
|||
bounds.lower_right() - point(border.right + padding.right, border.bottom),
|
||||
);
|
||||
|
||||
cx.with_z_index(style.z_index.unwrap_or(0), |cx| {
|
||||
style.paint(bounds, cx, |cx| {
|
||||
if self.item_count > 0 {
|
||||
let content_height =
|
||||
|
@ -224,8 +223,8 @@ impl Element for UniformList {
|
|||
let first_visible_element_ix =
|
||||
(-(scroll_offset.y + padding.top) / item_height).floor() as usize;
|
||||
let last_visible_element_ix =
|
||||
((-scroll_offset.y + padded_bounds.size.height) / item_height)
|
||||
.ceil() as usize;
|
||||
((-scroll_offset.y + padded_bounds.size.height) / item_height).ceil()
|
||||
as usize;
|
||||
let visible_range = first_visible_element_ix
|
||||
..cmp::min(last_visible_element_ix, self.item_count);
|
||||
|
||||
|
@ -249,9 +248,8 @@ impl Element for UniformList {
|
|||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
);
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue