Skip to content

Move or Drag a DOM to another position, Vue directive. 移动或拖拽一个 DOM 元素到其他位置,Vue 指令。

Notifications You must be signed in to change notification settings

evgo2017/vue-move-drag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vue-move-drag

version license downloads fork

中文 | English

Move or Drag a DOM to another position.

Demo

Full Usage Features:

https://evgo2017.com/repo/vue-move-drag

Install && Use

// npm or yarn
npm install vue-move-drag

// main.js
import vueMoveDrag from 'vue-move-drag'
Vue.use(vueMoveDrag)
// vue
<template>
  <div v-move-drag style="top: 50vh; left: 50vw; height: 100px; width: 100px; background: yellowgreen;z-index: 999;"></div>
</template>

// vue event
<template>
  <div v-move-drag @drag="handleDrag" style="top: 50vh; left: 50vw; height: 100px; width: 100px; background: yellowgreen;z-index: 999;"></div>
</template>

Advantage

  • PC Drag, Mobile Move;
  • Window Resize, the DOM will keep the original relative coordinate value; (To demo experience)
  • Border, the DOM won't be moved out Window;
  • Vue directive are easy to use.

Notice

  1. Directive will add draggable property to the DOM, and set its position to fixed.
  2. When unbind, directive will remove the resize event from window.

License

MIT - By evgo2017

About

Move or Drag a DOM to another position, Vue directive. 移动或拖拽一个 DOM 元素到其他位置,Vue 指令。

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages