修复第7条需求:确保拖动Panel标题栏能移动Area

This commit is contained in:
zqm
2025-11-04 14:34:40 +08:00
parent d9cd0518ca
commit 6c724b5903
3 changed files with 30 additions and 5 deletions

View File

@@ -126,12 +126,15 @@ const onDragStart = (e) => {
// 只有当点击的是标题栏区域(不是按钮)时才触发拖拽
if (!e.target.closest('.title-bar-buttons') && !e.target.closest('button')) {
isDragging = true;
// 传递panelId和鼠标位置
emit('dragStart', {
clientX: e.clientX,
clientY: e.clientY
clientY: e.clientY,
panelId: props.id
});
// 防止文本选择
// 防止文本选择和默认行为
e.preventDefault();
e.stopPropagation();
// 将鼠标移动和释放事件绑定到document确保拖拽的连续性
document.addEventListener('mousemove', onDragMove);
@@ -143,9 +146,13 @@ const onDragStart = (e) => {
// 拖拽移动
const onDragMove = (e) => {
if (isDragging) {
// 防止文本选择和默认行为
e.preventDefault();
e.stopPropagation();
emit('dragMove', {
clientX: e.clientX,
clientY: e.clientY
clientY: e.clientY,
panelId: props.id
});
}
};
@@ -154,7 +161,7 @@ const onDragMove = (e) => {
const onDragEnd = () => {
if (isDragging) {
isDragging = false;
emit('dragEnd');
emit('dragEnd', { panelId: props.id });
// 拖拽结束后移除事件监听器
document.removeEventListener('mousemove', onDragMove);