26 lines
758 B
JavaScript
26 lines
758 B
JavaScript
export default {
|
|
bind(el, binding) {
|
|
const dragDom = binding.value.$el.querySelector('.el-dialog');
|
|
|
|
el.onmousedown = (e) => {
|
|
|
|
/** 鼠标按下,计算当前元素距离可视区的距离*/
|
|
const disX = e.clientX - el.offsetLeft;
|
|
|
|
document.onmousemove = function (e) {
|
|
/** 移动时禁用默认事件*/
|
|
e.preventDefault();
|
|
|
|
/** 通过事件委托,计算移动的距离*/
|
|
const l = e.clientX - disX;
|
|
dragDom.style.width = `${l}px`;
|
|
};
|
|
|
|
document.onmouseup = function () {
|
|
document.onmousemove = null;
|
|
document.onmouseup = null;
|
|
};
|
|
};
|
|
}
|
|
};
|