refactor: extract dnd target and sidebar helpers
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
//! Block handle 拖拽命中的纯几何 helper。
|
||||
//! Block handle 拖拽命中的 runtime helper。
|
||||
//!
|
||||
//! 本模块不查询 DOM、不处理 Leptos signal,也不分发 editor command;
|
||||
//! 调用方负责传入已经从页面中读取的坐标。
|
||||
//! 本模块只承接拖拽命中所需的窄 helper,不处理 Leptos signal,
|
||||
//! 也不分发 editor command;调用方负责保留编辑器状态编排。
|
||||
|
||||
use crate::editor_runtime::block_hover_state::DropPlacement;
|
||||
use web_sys::{window, EventTarget};
|
||||
|
||||
pub(crate) struct HandleCorridorGeometry {
|
||||
pub(crate) stage_left: f64,
|
||||
@@ -56,6 +57,13 @@ pub(crate) fn drop_indicator_top(
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn event_target_from_point(client_x: i32, client_y: i32) -> Option<EventTarget> {
|
||||
window()
|
||||
.and_then(|win| win.document())
|
||||
.and_then(|document| document.element_from_point(client_x as f32, client_y as f32))
|
||||
.map(Into::into)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user