Skip to content

Commit 136050d

Browse files
jevin98sleeprite
authored andcommitted
!450 fix(layer): 拖拽至iframe区域防止mousemove事件被中断
* fix(layer): 拖拽至iframe区域防止mousemove事件被中断
1 parent 6fb618e commit 136050d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/layer/src/composable/useDragable.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ function getParentNode(el: any) {
88
return null;
99
}
1010

11+
// 处理mousemove到iframe区域会造成事件中断
12+
const handleIframeEvent = (value: "none" | "auto") => {
13+
const iframeDoms = document.querySelectorAll(".layui-layer iframe");
14+
15+
iframeDoms.forEach((iframe) => {
16+
(iframe as HTMLIFrameElement).style.pointerEvents = value;
17+
});
18+
};
19+
1120
const useMove = function (
1221
el: HTMLElement,
1322
moveOut: boolean,
@@ -24,6 +33,8 @@ const useMove = function (
2433
const path = (event.composedPath && event.composedPath()) || event.path;
2534
if (path[0].className === "layui-layer-title") {
2635
if (event.button == 0 && el != null) {
36+
handleIframeEvent("none");
37+
2738
const cs: any = getComputedStyle(el);
2839
offsetX = event.pageX - el.offsetLeft + parseInt(cs["margin-left"]);
2940
offsetY = event.pageY - el.offsetTop + parseInt(cs["margin-right"]);
@@ -81,6 +92,7 @@ const useMove = function (
8192
flag = true;
8293
// 说明结束,传递 moveEnd 事件
8394
endCallback();
95+
handleIframeEvent("auto");
8496
document.removeEventListener("mousemove", move);
8597
document.removeEventListener("mouseup", stop);
8698
};
@@ -107,6 +119,8 @@ const useResize = function (
107119
const path = (event.composedPath && event.composedPath()) || event.path;
108120
if (path[0].className === "layui-layer-resize") {
109121
if (event.button == 0 && el != null) {
122+
handleIframeEvent("none");
123+
110124
const x = el.offsetLeft;
111125
const y = el.offsetTop;
112126
clientX = event.clientX;
@@ -141,6 +155,7 @@ const useResize = function (
141155
flag = true;
142156
// 说明结束,传递 moveEnd 事件
143157
endCallback();
158+
handleIframeEvent("auto");
144159
document.removeEventListener("mousemove", move);
145160
document.removeEventListener("mouseup", stop);
146161
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy