当前位置:网站首页>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 .
边栏推荐
- 网站设计需要的基本知识
- 2019 ICPC Asia Yinchuan Regional(水题题解)
- JS 一行代码 获取数组最大值与最小值
- Sublime install plug-ins
- 在Blazor 中自定义权限验证
- 云原生(三十六) | Kubernetes篇之Harbor入门和安装
- Fiddler packet capturing tool for mobile packet capturing
- copyTo
- Why does new public chain Aptos meet market expectations?
- 解决ProxyError: Conda cannot proceed due to an error in your proxy configuration.
猜你喜欢

Redis sentinel mode setup under Windows

Fiddler download and installation

The diagram of user login verification process is well written!
![Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res](/img/8e/265af6b20f79b21c3eadcd70cfbdf7.png)
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res

Gauss elimination

Keeping alive to realize MySQL automatic failover
![[datawhale] [machine learning] Diabetes genetic risk detection challenge](/img/98/7981af7948feb73168e5200b3dfac9.png)
[datawhale] [machine learning] Diabetes genetic risk detection challenge

2019 ICPC Asia Yinchuan regional (water problem solution)

2022年中科磐云——服务器内部信息获取 解析flag

spolicy请求案例
随机推荐
Basic knowledge of website design
In the same CONDA environment, install pytroch first and then tensorflow
JS judge the data types object.prototype.tostring.call and typeof
高斯消元的应用
Network flow learning notes
论文笔记(SESSION-BASED RECOMMENDATIONS WITHRECURRENT NEURAL NETWORKS)
JS table auto cycle scrolling, mouse move in pause
Qt随手笔记(二)Edit控件及float,QString转化、
服务发现原理分析与源码解读
解释一下自动装箱和自动拆箱?
E. Two Small Strings
高斯消元求解异或线性方程组
PHP executes shell script
在.NET 6.0中配置WebHostBuilder
B站这个视频我是跪着看完的
Sqoop [environment setup 01] CentOS Linux release 7.5 installation configuration sqoop-1.4.7 resolve warnings and verify (attach sqoop 1 + sqoop 2 Latest installation package +mysql driver package res
Wechat H5 payment on WAP, for non wechat browsers
Login module use case writing
Fuzzy PID control of motor speed
Sublime install plug-ins