0.0.3 • Published 1 year ago

el-dragmove v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

使用文档 | Usage

拖动模型.gif

在线demo | Online Demo

使用示例

CDN方式使用 | Using with CDN

<div id="rect-1" class="rect">1</div>

<script src="https://unpkg.com/el-dragmove@latest/dist/index.min.js"></script>
<script>
  const targetEl = document.getElementById('rect-1')
  const moveModel = new DragMoveModel({ targetEl: targetEl }, (x, y, z) => console.log(x, y, z))
</script>

模块化项目中使用 | Using in Project

  1. 安装 | install
npm i el-dragmove@latest -S
  1. 引入 | import el-dragmove
import Dragmove from 'el-dragmove/dist/es'

const el = document.getElementById('test')
const elDragmove = new Dragmove({
  targetEl: el
})

// 销毁监听事件
// elDragmove.destroy()

构造函数初始化参数 | Initialize some parameters

  • config,个性化配置
  • callback, 回调函数,获取鼠标移动距离

config参数配置 | config`s properties

属性 property说明 description类型 type默认值 defalut可选值 optional
targetEl目标元素,需要拖动的元素The element that needs to be draggedHTMLElementdocument.body
limitMoveBorder是否限制拖动边界Whether to restrict drag boundariesBooleanfalse
moveMode拖动实现方式,transform为transform-translate方式移动,position为top,left方式移动Drag implementationStringtransformtransform,position
h5是否是h5Whether it is H5 or notBooleanfalse
disableMoveEl是否限制移动Whether to restrict movementBooleanfalse
maxMoveXx轴最大移动距离Maximum distance traveled on the x-axisNumber1000000
maxMoveYy轴最大移动距离Maximum distance traveled on the y-axisNumber1000000

销毁方法 | Destroy

moveModel.destroy()

实现原理解析 | How to implement

https://juejin.cn/post/7165405623725588493

0.0.3

1 year ago

0.0.2-dev.1

1 year ago

0.0.2-beta.3

2 years ago

0.0.2-beta.2

2 years ago

0.0.2-beta

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago