Skip to content

Commit 2100555

Browse files
Update README.md
1 parent 5bb0e42 commit 2100555

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

README.md

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,69 @@
1-
# dragdroptouch
1+
# DragDropTouch
2+
23
Polyfill that enables HTML5 drag drop support on mobile (touch) devices.
4+
5+
The HTML5 specification includes support for drag and drop operations.
6+
Unfortunately, most mobile browsers do not implement it, so applications
7+
that rely on HTML5 drag and drop have reduced functionality when running
8+
on mobile devices.
9+
10+
The DragDropTouch class is a polyfill that translates touch events into
11+
standard HTML5 drag drop events. If you add the polyfill to your pages,
12+
drag and drop operations should work on mobile devices just like they
13+
do on the desktop.
14+
15+
## Demo
16+
17+
- [drag drop](http://timruffles.github.io/ios-html5-drag-drop-shim/demo/)
18+
- [drag drop with enter leave support](http://timruffles.github.io/ios-html5-drag-drop-shim/enter-leave/)
19+
20+
The demo should work on desktop as well as on mobile devices, including
21+
iPads and Android tablets.
22+
23+
The top section of the demo is based on a well-known HTML5 drag and drop
24+
sample available here:
25+
26+
The following sections demonstrate how the polyfill works with
27+
standards-based components that use HTML5 drag and drop. You can use
28+
touch to resize and reorder grid columns, data groups, and pivot
29+
fields.
30+
31+
## Install
32+
33+
Add the DragDropTouch.js polyfill to your page to enable drag and drop on mobile devices:
34+
35+
```html
36+
<script src="DragDropTouch.js"></script>
37+
```
38+
39+
## Polyfill behaviour
40+
41+
The **DragDropTouch** polyfill attaches listeners to the document's touch events:
42+
43+
- On **touchstart**, it checks whether the target element has the draggable attribute
44+
or is contained in an element that does. If that is the case, it saves a reference
45+
to the "drag source" element and prevents the default handling of the event.
46+
- On **touchmove**, it checks whether the touch has moved a certain threshold distance
47+
from the origin. If that is the case, it raises the **dragstart** event and continues
48+
monitoring moves to fire **dragenter** and **dragleave**.
49+
- On **touchend**, it raises the **dragend** and **drop** events.
50+
51+
To avoid interfering with the automatic browser translation of some touch events into
52+
mouse events, the polyfill performs a few additional tasks:
53+
54+
- Raise the **mousemove**, **mousedown**, **mouseup**, and **click** events when the
55+
user touches a draggable element but doesn't start dragging,
56+
- Raise the **dblclick** event when there's a new touchstart right after a click, and
57+
- Raise the **contextmenu** event when the touch lasts a while but the user doesn't
58+
start dragging the element.
59+
60+
## Thanks
61+
62+
Thanks to Eric Bidelman for the great tutorial on HTML5 drag and drop: [Native HTML5 Drag and Drop] (http://www.html5rocks.com/en/tutorials/dnd/basics/).
63+
64+
Thanks also to Chris Wilson and Paul Kinlan for their article on mouse and touch events: [Touch And Mouse] (http://www.html5rocks.com/en/mobile/touchandmouse/).
65+
66+
## License
67+
68+
[MIT License](LICENSE)
69+

0 commit comments

Comments
 (0)