Vue 弹框拖动和双击全屏功能实现 - 解决放大后弹框进入页面上方没法拖动问题
在双击全屏的代码中,加上以下代码:
document.onmousemove = function (e) {
const l = e.clientX - disX;
const t = e.clientY - disY;
const maxX = document.body.clientWidth - dragDom.offsetWidth; //最大横向移动距离
const maxY = document.body.clientHeight - dragDom.offsetHeight; //最大纵向移动距离
let left = l + styL;
let top = t + styT;
left = left < 0 ? 0 : left;
left = left > maxX ? maxX : left;
top = top < 0 ? 0 : top;
top = top > maxY ? maxY : top;
dragDom.style.left = `${left}px`;
dragDom.style.top = `${top}px`;
};
这样在全屏后也能拖动弹框了。
原文地址: https://www.cveoy.top/t/topic/oKS2 著作权归作者所有。请勿转载和采集!