https://github.com/mikedevelops/vanilla-drag
Drag HTML elements, nothing more, nothing less.
https://github.com/mikedevelops/vanilla-drag
Last synced: about 2 months ago
JSON representation
Drag HTML elements, nothing more, nothing less.
- Host: GitHub
- URL: https://github.com/mikedevelops/vanilla-drag
- Owner: mikedevelops
- Created: 2017-09-30T10:45:25.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-12T08:54:54.000Z (about 6 years ago)
- Last Synced: 2025-10-24T06:27:39.785Z (8 months ago)
- Language: JavaScript
- Size: 104 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Vanilla Drag
[](https://travis-ci.org/mikedevelops/vanilla-drag)
A _tiny_ (5KB) package to allow free dragging of HTML elements.
[Example](http://michaelsmart.co.uk/playground/vanilla-drag)
## Installation
```shell
npm install --save vanilla-drag
```
## Getting Started
```javascript
import VanillaDrag from 'vanilla-drag';
const target = document.getElementById('target');
const drag = new VanillaDrag(window, target);
```
## Options
The VanillaDrag constructor takes two arguments.
```javascript
new VanillaDrag([window], [HTMLElement])
```
### [window]
The current context's window object. 99% of the time this will always be a case of passing in the global `window` object.
### [HTMLElement]
An instance of a `HTMLElement` that will have dragging enabled. Jquery users can access an instance of this object using the following Jquery index / method `$('#target')[0]` or `$('#target').get(0)`. For Jquery collections containing multiple elements, the collection will need to be iterated over and a separate instance of VanillaDrag created for each item.