Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heyman/jquery-draggable-touch
Make HTML elements draggable using touch events
https://github.com/heyman/jquery-draggable-touch
Last synced: 1 day ago
JSON representation
Make HTML elements draggable using touch events
- Host: GitHub
- URL: https://github.com/heyman/jquery-draggable-touch
- Owner: heyman
- Created: 2013-02-06T16:02:14.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-11-13T12:56:57.000Z (almost 3 years ago)
- Last Synced: 2023-04-13T15:37:14.896Z (over 1 year ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 42
- Watchers: 5
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
jQuery Draggable Touch
======================Make HTML elements draggable, and supports multi touch. Main implementation uses
touch events, but the plugin also has a fallback that uses mouse events.The main reason that this plugin exist is that there are currently no
good jQuery plugin for making elements draggable, that has touch devices
as it's main target (at least that I know of). `jQuery UI `_
has a draggable plugin which, together with `jQuery UI Touch Punch `_,
can be used to make elements draggable on touch devices. However, due to
Touch Punch generating fake mouse events, and jQuery UI's draggable plugin, using these fake
mouse events when dragging elements, it's error prone and contains weird bugs.I decided it was simpler to just write a draggable plugin whose main target
was touch devices, and that uses touch events (even though it still has a
fallback on mouseevents when the browser/device doesn't support touch events).Features
--------* Main target is touch devices
* Small and simple
* Supports dragging multiple elements at the same timeUsage example
-------------::
$(".my-draggables")
.draggableTouch()
.bind("dragstart", function(event, pos) {
console.log("drag started on:", this, "at position:", pos);
})
.bind("dragend", function(event, pos) {
console.log("drag ended on:", this, "at position:", pos);
});Set the position using :code:`transform` CSS property instead of :code:`left` and :code:`top`::
$(".my-draggables").draggableTouch({useTransform:true});
To disable dragability::
$(".my-draggables").draggableTouch("disable");
See example
-----------`Here `_ is a super simple
- and frankly quite ugly - example page.Copyright & License
-------------------This plugin is written by `Jonatan Heyman `_ and is licenced as
`Beerware `_.