elementui弹框拖拽和放大缩小 第二节
作者:互联网
function setMaxMin(){
if (isFullScreen == false) {
let i = maxMin.querySelector('.el-icon-full-screen');
i.classList.remove('el-icon-full-screen');
i.classList.add('fa-expand');
maxMin.title = '还原';
// bodyHeight = dragDom.querySelector('.el-dialog__body').offsetHeight+'px';
// nowHight = dragDom.clientHeight;
nowWidth = dragDom.clientWidth;
nowMarginTop = dragDom.style.marginTop;
dragDom.style.left = 0;
dragDom.style.top = 0;
dragDom.style.height = "auto";
dragDom.style.width = "100%";
dragDom.style.marginTop = 0;
isFullScreen = true;
dialogHeaderEl.style.cursor = 'initial';
dialogHeaderEl.onmousedown = null;
if(!hasSetBodyHight) {
dragDom.querySelector('.el-dialog__body').style.height = 'calc(100% - '+dialogHeaderEl.offsetHeight+'px)';
hasSetBodyHight = true;
}
} else {
let i = maxMin.querySelector('.fa-expand');
i.classList.remove('fa-expand');
i.classList.add('el-icon-full-screen');
maxMin.innerHTML = '<i class="fa el-icon-full-screen"></i>';
maxMin.title = '最大化';
dragDom.style.height = "auto";
dragDom.style.width = nowWidth + 'px';
dragDom.style.marginTop = nowMarginTop;
isFullScreen = false;
dialogHeaderEl.style.cursor = 'move';
dialogHeaderEl.onmousedown = moveDown;
dragDom.querySelector('.el-dialog__body').style.height = 'auto';
hasSetBodyHight = false;
}
}
//点击放大缩小效果
maxMin.onclick = setMaxMin;
//双击头部效果
dialogHeaderEl.ondblclick = setMaxMin;
//拉伸
let resizeEl=document.createElement("div");
dragDom.appendChild(resizeEl);
//在弹窗右下角加上一个10-10px的控制块
resizeEl.style.cursor = 'se-resize';
resizeEl.style.position = 'absolute';
resizeEl.style.height = '10px';
resizeEl.style.width = '10px';
resizeEl.style.right = '0px';
resizeEl.style.bottom = '0px';
标签:el,style,resizeEl,elementui,拖拽,弹框,dialogHeaderEl,maxMin,dragDom 来源: https://www.cnblogs.com/Mr-dongjuntao/p/16249366.html