拖拽时,多窗口相互独立
This commit is contained in:
@@ -377,8 +377,13 @@ const onDragStart = (e) => {
|
|||||||
|
|
||||||
// 拖拽移动 - 处理事件总线的area.drag.move事件
|
// 拖拽移动 - 处理事件总线的area.drag.move事件
|
||||||
const onDragMove = (eventData) => {
|
const onDragMove = (eventData) => {
|
||||||
// 从事件数据中获取位置信息
|
// 从事件数据中获取位置信息和areaId
|
||||||
const { left, top, dragId } = eventData
|
const { left, top, dragId, areaId } = eventData
|
||||||
|
|
||||||
|
// 只有当事件的areaId与当前组件的id匹配时,才更新位置
|
||||||
|
if (areaId !== props.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 只使用明确提供的left和top值,不直接使用position.x和position.y
|
// 只使用明确提供的left和top值,不直接使用position.x和position.y
|
||||||
if (left !== undefined) {
|
if (left !== undefined) {
|
||||||
@@ -401,7 +406,12 @@ const onDragMove = (eventData) => {
|
|||||||
|
|
||||||
// 拖拽结束 - 处理事件总线的area.drag.end事件
|
// 拖拽结束 - 处理事件总线的area.drag.end事件
|
||||||
const onDragEnd = (eventData) => {
|
const onDragEnd = (eventData) => {
|
||||||
const { dragId, finalPosition } = eventData
|
const { dragId, finalPosition, areaId } = eventData
|
||||||
|
|
||||||
|
// 只有当事件的areaId与当前组件的id匹配时,才处理拖拽结束
|
||||||
|
if (areaId !== props.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 如果提供了finalPosition,更新位置
|
// 如果提供了finalPosition,更新位置
|
||||||
if (finalPosition) {
|
if (finalPosition) {
|
||||||
|
|||||||
Reference in New Issue
Block a user