https://github.com/gtramontina/draggable.js
Make your DOM elements draggable easily
https://github.com/gtramontina/draggable.js
Last synced: 3 months ago
JSON representation
Make your DOM elements draggable easily
- Host: GitHub
- URL: https://github.com/gtramontina/draggable.js
- Owner: gtramontina
- Created: 2012-01-21T04:10:16.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2016-11-06T09:26:15.000Z (over 8 years ago)
- Last Synced: 2025-02-27T17:56:16.002Z (3 months ago)
- Language: JavaScript
- Homepage: http://gtramontina.github.com/draggable.js/
- Size: 166 KB
- Stars: 121
- Watchers: 14
- Forks: 26
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# draggable.js [](https://travis-ci.org/gtramontina/draggable.js) [](https://codecov.io/github/gtramontina/draggable.js?branch=master) [](https://bitdeli.com/free "Bitdeli Badge")
##### Make your DOM elements draggagle easily### Examples
DOM:
```html
```To make the whole element draggable:
```javascript
var elementToDrag = document.getElementById('elementToDrag');
draggable(elementToDrag);
```To make it draggable only when dragging the handle element:
```javascript
var elementToDrag = document.getElementById('elementToDrag');
var handle = elementToDrag.getElementsByClassName('handle')[0];
draggable(elementToDrag, handle);
```#### Notes
* You have to provide the raw element, not the one wrapped by your favorite dom query lib. Using jQuery, for example, you'd need to do something like `var elementToDrag = $('#elementToDrag').get(0);`
* If you are using AMD (e.g. require.js) this lib becomes a module. Otherwise it'll create a global `draggable`.### Browser Compatibility
I've ran the tests in Chrome and Firefox. On [travis-ci](https://travis-ci.org/gtramontina/draggable.js) the tests run in Phantomjs. If you find any incompatibility or want to support other browsers, please do a pull request with the fix! :-)### Development
*Prerequisites*
[phantomjs](http://phantomjs.org/download.html)
mocha `npm install mocha`### License
This is licensed under the feel-free-to-do-whatever-you-want-to-do license.