Skip to content

Vue draggable component (v-drag). Vue.jsのドラッガブル ディレクティブ (v-drag)

Notifications You must be signed in to change notification settings

androidfanatic/v-drag

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

v-drag - a supler simple, Vue.js draggable component.

Use

Node.js env (such a .vue components):

<template>
  <div>
    <div style="position: absolute;" v-drag>
    </div>
  </div>
</template>

<script>
import drag from '@androidfanatic/v-drag'

export default {
  directives: {
    drag
  }
}
</script>

Browser env: coming soon.

Notes

An element with v-drag must have position: absolute; to be draggable.

Options

You may desire only one part of an element to be draggable. You can achieve this by passing a string which refers to an id as argument to v-drag.

<div id="header">
  <div v-drag:header>
    <div>
      Some text
    </div>
  </div>
</div>

This will result in any area that is not <div id="header"> not becoming draggable. One common use case is a modal, that is only draggable when the top area is clicked.

You can constrain the draggable object from leaving the viewport by using the window-only modifier like so:

<div v-drag.window-only>
  This element cannot be dragged outside the window
</div>

Other

Original source: https://github.com/branu-ws/v-drag

Built by, for and at BRANU. Our open source projects can be found on our npm page: https://www.npmjs.com/org/branu-jp

v-drag npm link: https://www.npmjs.com/package/@branu-jp/v-drag

About

Vue draggable component (v-drag). Vue.jsのドラッガブル ディレクティブ (v-drag)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%