最近项目里常常使用拖拽改变元素位置或者大小的需求,cv法文件找的脑阔疼,索性试试写一个指令。

说起指令,提一嘴,vue3没有了根元素唯一的限制后,仿佛指令绑定在组件上就不能生效了。

import type { Directive } from 'vue'
const mouseDownMove: Directive = {
mounted(el, binding) {
const { mouseDown, mouseMove, mouseUp } = binding.value
el.onmousedown = (event) => {
mouseDown && mouseDown(event)
document.onselectstart = function () {
return false
}
document.ondragstart = function () {
return false
}
document.onmousemove = (event) => {
mouseMove && mouseMove(event)
}
window.onmouseup = (event) => {
document.onmousemove = null
document.onselectstart = null
window.onmouseup = null
document.ondragstart = null
mouseUp && mouseUp(event)
      <span class="xy-scrollbar__thumb"
:style="thumbX"
v-mouseDownMove="handleMouseDownX"></span>
const mouseDownMove = {
mouseDown(){},
mouseMove(){},
mouseUp(){},
}

最新文章

  1. Java MySql 批量插入数据库addBatch
  2. 深入Java核心 Java中多态的实现机制(1)
  3. dotnet文件操作
  4. .net 架构师/经理招聘,长期有效
  5. svn代码回滚命令
  6. POJ 2992 Divisors
  7. 转:ASCII码表_全_完整版
  8. andengine游戏引擎总结基础篇
  9. grunt安装使用简介
  10. 一次php涉及跨域功能的麻烦及解决方案
  11. Java中的回调
  12. [SDOI2015]序列统计
  13. mybatis数据源源码剖析(JNDI、POOLED、UNPOOLED)
  14. 免费了 -- EXCEL插件 智表ZCELL 普及版V1.0 发布了!!!
  15. centos 7 之nginx
  16. 1.Ansible安装以及配置
  17. (转)Spring文件上传,包括一次选中多个文件
  18. Gym - 101002D:Programming Team (01分数规划+树上依赖背包)
  19. Oracle 存储过程了解
  20. how to create a custom form for sharepoint list

热门文章

  1. 第五章:Admin管理后台 - 2:自定义Admin actions
  2. Elasticsearch from/size-浅分页查询-深分页 scroll-深分页search_after深度查询区别使用及应用场景
  3. C++面向对象编程之C++11语法糖
  4. 关于maven插件在Myeclipse中的使用
  5. 使用开源计算引擎提升Excel格式文件处理效率
  6. 测试杂谈——一条SQL引发的思考(二)
  7. instanceof的使用和向下转型
  8. [Thread] 多线程顺序执行
  9. 虚拟机安装Linux系统的网络配置
  10. resutful的使用和增强版的swagger2