1.0.1 • Published 4 years ago

pure-drag v1.0.1

Weekly downloads
86
License
ISC
Repository
github
Last release
4 years ago

INSTALL

npm install pure-drag

or

yarn add pure-drag

USAGE

css

#dragparent {
    position: relative;
    width: 500px;
    height: 500px;
    border: 1px solid red
}
#dragson {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: blue;
}

html

<div id="dragparent">
    <div id="dragson"></div>
</div>

js

Drag at the parent

import Drag from 'pure-drag'

let dragParent = document.getElementById('dragparent'),
    dragSon = document.getElementById('dragson')

new Drag({
    parent: dragParent,
    dragEle: dragSon
})

Global drag

import Drag from 'pure-drag'
new Drag({
    dragEle: document.getElementById('dragson')
})