提交 b7af1ad5 authored 作者: 钟是志's avatar 钟是志

iframe中无法拖拽的bug

上级 9fb638fb
...@@ -49,7 +49,9 @@ const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => { ...@@ -49,7 +49,9 @@ const ShowItem = ({ basicUrl, type, x, y, ...otherInfo }) => {
export const dragEventList = (setOtherProps, otherProps) => { export const dragEventList = (setOtherProps, otherProps) => {
let draggedRef = null; let draggedRef = null;
document.addEventListener( let documentThis = window?.parent?.iframeParentComponent?.Modal ? window?.parent?.document : document;
documentThis.addEventListener(
'dragstart', 'dragstart',
function(event) { function(event) {
// 保存拖动元素的引用(ref.) // 保存拖动元素的引用(ref.)
...@@ -58,7 +60,7 @@ export const dragEventList = (setOtherProps, otherProps) => { ...@@ -58,7 +60,7 @@ export const dragEventList = (setOtherProps, otherProps) => {
}, },
false, false,
); );
document.addEventListener( documentThis.addEventListener(
'dragend', 'dragend',
(event) => { (event) => {
// 重置透明度 // 重置透明度
...@@ -68,7 +70,7 @@ export const dragEventList = (setOtherProps, otherProps) => { ...@@ -68,7 +70,7 @@ export const dragEventList = (setOtherProps, otherProps) => {
); );
/* 放下目标节点时触发事件 */ /* 放下目标节点时触发事件 */
document.addEventListener( documentThis.addEventListener(
'dragover', 'dragover',
(event) => { (event) => {
// 阻止默认动作 // 阻止默认动作
...@@ -76,13 +78,13 @@ export const dragEventList = (setOtherProps, otherProps) => { ...@@ -76,13 +78,13 @@ export const dragEventList = (setOtherProps, otherProps) => {
}, },
false, false,
); );
document.addEventListener( documentThis.addEventListener(
'drop', 'drop',
(event) => { (event) => {
// 阻止默认动作(如打开一些元素的链接) // 阻止默认动作(如打开一些元素的链接)
event.preventDefault(); event.preventDefault();
// 将拖动的元素到所选择的放置目标节点中 // 将拖动的元素到所选择的放置目标节点中
let infoClientRect = document.getElementById('dropZone').getBoundingClientRect(); let infoClientRect = documentThis.getElementById('dropZone').getBoundingClientRect();
let leftNew = Math.ceil(event.clientX - infoClientRect.left); let leftNew = Math.ceil(event.clientX - infoClientRect.left);
let topNew = Math.ceil(event.clientY - infoClientRect.top); let topNew = Math.ceil(event.clientY - infoClientRect.top);
if(leftNew < 0 || leftNew > infoClientRect.width || topNew < 0 || topNew > infoClientRect.height){ if(leftNew < 0 || leftNew > infoClientRect.width || topNew < 0 || topNew > infoClientRect.height){
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论