Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/albertogasparin/dragble
Tiny JS lib to drag elements around, on desktop and mobile
https://github.com/albertogasparin/dragble
Last synced: about 4 hours ago
JSON representation
Tiny JS lib to drag elements around, on desktop and mobile
- Host: GitHub
- URL: https://github.com/albertogasparin/dragble
- Owner: albertogasparin
- License: mit
- Created: 2015-07-01T07:44:05.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-06T11:45:44.000Z (over 9 years ago)
- Last Synced: 2024-04-28T04:34:40.832Z (7 months ago)
- Language: JavaScript
- Size: 125 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Dragble
Dragble.js is a tiny JavaScript library for creating draggable elements.
It has not dependencies and works on IE9+ and touch devices.## Usage
You use the following syntax to create a new draggy object:
new Dragble(element, config)
# Options
element (required)
DOM element or selector of the draggy object
config (optional)
Optional configuration object
Configuration OptionsFollowing configuration options are available when creating the draggy object:
bindTo (string or element)
DOM element (or selector) to which the draggy object is constrained by
limitsX (array with start and end values (numbers))
Manual setting limiting horizontal movement
limitsY (array with start and end values (numbers))
Manual setting limiting vertical movement
onChange (function)
Callback that will be called when the object is dragged
restrictX (boolean)
Make it impossible to move the object horizontally
restrictY (boolean)
Make it impossible to move the object vertically# API
Once a draggy object has been created it can be manipulated with the following API:
ele
Returns the DOM element of the draggy object
position
Current position of the element. Returns array with x and y value
bind(element)
Restrict draggy object to boundaries of an element
destroy()
Remove Draggy from element. Should be called before removing element from DOM.
disable()
Disable dragging functionality of object
enable()
Enable dragging functionality of object## Thanks
This library started as a fork of [Stefan Liden's Draggy.js](http://jofan.github.com/Draggy/)