当前位置:网站首页>Production of a-modal drag function in antui
Production of a-modal drag function in antui
2022-07-26 09:52:00 【Zhou Xiaotiao】
Blogging is for taking notes !!!
antUI in a-modal Drag function production
List of articles
One 、 stay utils Created in drag.js file , The contents are as follows :
import Vue from 'vue'
// v-dialogDrag: Pop up drag
Vue.directive('dragModal', {
bind(el, binding, vnode, oldVnode) {
const dialogHeaderEl = el.querySelector('.ant-modal-header')
const dragDom = el.querySelector('.ant-modal')
dialogHeaderEl.style.cursor = 'move'
// Get the original properties ie dom Elements .currentStyle Fox, Google window.getComputedStyle(dom Elements , null);
const sty = dragDom.currentStyle || window.getComputedStyle(dragDom, null)
dialogHeaderEl.onmousedown = (e) => {
// The mouse click , Calculate the distance between the current element and the visible area
const disX = e.clientX - dialogHeaderEl.offsetLeft
const disY = e.clientY - dialogHeaderEl.offsetTop
// Get the value band px Regular match replacement
let styL, styT
// Pay attention to ie in The value obtained for the first time is the component's own 50% After moving, the assignment is px
if (sty.left.includes('%')) {
styL = +document.body.clientWidth * (+sty.left.replace(/\%/g, '') / 100)
styT = +document.body.clientHeight * (+sty.top.replace(/\%/g, '') / 100)
} else {
styL = +sty.left.replace(/\px/g, '')
styT = +sty.top.replace(/\px/g, '')
}
document.onmousemove = function (e) {
// Through event delegation , Calculate the distance of movement
const l = e.clientX - disX
const t = e.clientY - disY
// Move the current element
dragDom.style.left = `${
l + styL}px`
dragDom.style.top = `${
t + styT}px`
// Send out the position at this time
// binding.value({
x:e.pageX,y:e.pageY})
}
document.onmouseup = function (e) {
document.onmousemove = null
document.onmouseup = null
}
}
}
})
Two 、 stay main.js Introduction in :
import '@/utils/drag'
3、 ... and 、 Use :
Pay attention to the command and the top drag.js Consistency stated in .
Then the pop-up window can be dragged .
summary
If you want to make other UI Popup drag function in the frame , Only need to drag.js Replace the elements in .
边栏推荐
- JS table auto cycle scrolling, mouse move in pause
- MFC handy notes
- CSV data file settings of JMeter configuration components
- Gauss elimination for solving XOR linear equations
- Sqoop【付诸实践 02】Sqoop1最新版 全库导入 + 数据过滤 + 字段类型支持 说明及举例代码(query参数及字段类型强制转换)
- 服务器、客户端双认证(2)
- What is the principle of reflection mechanism?
- Qt随手笔记(三)在vs中使用QtCharts画折线图
- (二)面扫描仪与机械臂的手眼标定(眼在手外:九点标定)
- Solve NPM -v sudden failure and no response
猜你喜欢
高斯消元求解矩阵的逆(gauss)
[datawhale] [machine learning] Diabetes genetic risk detection challenge
2019 ICPC Asia Yinchuan regional (water problem solution)
Logical architecture of MySQL
Keeping alive to realize MySQL automatic failover
高斯消元
服务器内存故障预测居然可以这样做!
Spolicy request case
2021 windows penetration of "Cyberspace Security" B module of Shandong secondary vocational group (analysis)
面试突击68:为什么 TCP 需要 3 次握手?
随机推荐
IIS website configuration
服务器、客户端双认证(2)
2021年山东省中职组“网络空间安全”B模块windows渗透(解析)
MySQL 5.7.25 source code installation record
Due to fierce competition in the new market, China Mobile was forced to launch a restrictive ultra-low price 5g package
莫队学习笔记(一)
Interview shock 68: why does TCP need three handshakes?
JS continuous assignment operation
反射机制的原理是什么?
[information system project manager] summary of essence of high-level series for the first time
Uni app learning summary
服务器、客户端双认证
阿里云技术专家郝晨栋:云上可观测能力——问题的发现与定位实践
Login module use case writing
I finished watching this video on my knees at station B
asp. Net using redis cache
Solve NPM -v sudden failure and no response
What is the principle of reflection mechanism?
Unstoppable, pure domestic PCs have been in place, and the monopoly of the U.S. software and hardware system has been officially broken
面试突击68:为什么 TCP 需要 3 次握手?