You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,24 @@
1
+
# 1.4.0 (2016-02-06)
2
+
3
+
## Features
4
+
5
+
-**dnd-handle directive**: This directive can be used in combination with `dnd-nodrag`, so that a `dnd-draggable` can only be dragged by using certain handle elements. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
6
+
-**dnd-drop can handle insertion**: The `dnd-drop` callback can now return true to signalize that it will take care of inserting the dropped element itself. `dnd-list` will then no longer insert any elements into the list, but will still call the `dnd-inserted` callback.
7
+
8
+
## Bug Fixes
9
+
10
+
-**Fix dnd-disable-if on dnd-draggable**: When you disabled a `dnd-draggable` with `dnd-disable-if`, the user was still able to trigger a drag of that element by selecting some text inside the element. (issue #159)
11
+
-**dnd-list now handles the dragenter event**: According to the HTML5 standard dropzones need to handle the `dragenter` event, although there doesn't seem to be any browser that enforces this. (issue #118)
12
+
13
+
## Tested browsers
14
+
15
+
- Chrome 48 (Mac, Ubuntu & Windows 10)
16
+
- Firefox 44 (Ubuntu)
17
+
- Safari 9 (Mac)
18
+
- Microsoft Edge 20 (Windows 10)
19
+
- Internet Explorer 11 (Windows 10)
20
+
- Internet Explorer 10 & 9 in compatibility mode (Windows 10)
Copy file name to clipboardExpand all lines: README.md
+41-22Lines changed: 41 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,18 @@ angular-drag-and-drop-lists
3
3
Angular directives that allow you to build sortable lists with the native HTML5 drag & drop API. The directives can also be nested to bring drag & drop to your WYSIWYG editor, your tree, or whatever fancy structure you are building.
Internet Explorer 8 or lower is *not supported*, but all modern browsers are (see changelog for tested versions).
15
+
**Touch devices are not supported**, because they do not implement the HTML5 drag & drop standard. However, you can use a [shim](https://github.com/timruffles/ios-html5-drag-drop-shim) to make it work on touch devices as well.
15
16
16
-
Note that **touch devices are not supported**, because the HTML5 drag & drop standard doesn't cover those. You can try to use a [shim](https://github.com/timruffles/ios-html5-drag-drop-shim) for that though.
17
+
Internet Explorer 8 or lower is *not supported*, but all modern browsers are (see changelog for list of tested browsers).
17
18
18
19
19
20
## Download & Installation
@@ -28,20 +29,20 @@ Use the dnd-draggable directive to make your element draggable
28
29
*`move` The drag operation will move the element. This is the default
29
30
*`copy` The drag operation will copy the element. There will be a copy cursor.
30
31
*`copyMove` The user can choose between copy and move by pressing the ctrl or shift key.
31
-
**Not supported in IE:* In Internet Explorer this option will be the same as `copy`.
32
+
**Not supported in IE:* In Internet Explorer this option will be the same as `copy`.
32
33
**Not fully supported in Chrome on Windows:* In the Windows version of Chrome the cursor will always be the move cursor. However, when the user drops an element and has the ctrl key pressed, we will perform a copy anyways.
33
34
* HTML5 also specifies the `link` option, but this library does not actively support it yet, so use it at your own risk.
*`dnd-type` Use this attribute if you have different kinds of items in your application and you want to limit which items can be dropped into which lists. Combine with dnd-allowed-types on the dnd-list(s). This attribute should evaluate to a string, although this restriction is not enforced (at the moment). [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
36
-
*`dnd-disable-if` You can use this attribute to dynamically disable the draggability of the element. This is useful if you have certain list items that you don't want to be draggable, or if you want to disable drag & drop completely without having two different code branches (e.g. only allow for admins). *Note*: If your element is not draggable, the user is probably able to select text or images inside of it. Since a selection is always draggable, this breaks your UI. You most likely want to disable user selection via CSS (see [user-select](http://stackoverflow.com/a/4407335)). [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
36
+
*`dnd-type` Use this attribute if you have different kinds of items in your application and you want to limit which items can be dropped into which lists. Combine with dnd-allowed-types on the dnd-list(s). This attribute should evaluate to a string, although this restriction is not enforced (at the moment). [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
37
+
*`dnd-disable-if` You can use this attribute to dynamically disable the draggability of the element. This is useful if you have certain list items that you don't want to be draggable, or if you want to disable drag & drop completely without having two different code branches (e.g. only allow for admins). *Note*: If your element is not draggable, the user is probably able to select text or images inside of it. Since a selection is always draggable, this breaks your UI. You most likely want to disable user selection via CSS (see [user-select](http://stackoverflow.com/a/4407335)). [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
37
38
38
39
**Callbacks**
39
40
*`dnd-moved` Callback that is invoked when the element was moved. Usually you will remove your element from the original list in this callback, since the directive is not doing that for you automatically. The original dragend event will be provided in the local `event` variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
40
41
*`dnd-copied` Same as dnd-moved, just that it is called when the element was copied instead of moved. The original dragend event will be provided in the local `event` variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
41
42
*`dnd-canceled` Callback that is invoked if the element was dragged, but the operation was canceled and the element was not dropped. The original dragend event will be provided in the local event variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
42
43
*`dnd-dragstart` Callback that is invoked when the element was dragged. The original dragstart event will be provided in the local `event` variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
43
44
*`dnd-dragend` Callback that is invoked when the drag operation ended. Available local variables are `event` and `dropEffect`. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
44
-
*`dnd-selected` Callback that is invoked when the element was clicked but not dragged. The original click event will be provided in the local `event` variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/nested)
45
+
*`dnd-selected` Callback that is invoked when the element was clicked but not dragged. The original click event will be provided in the local `event` variable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/nested)
45
46
46
47
**CSS classes**
47
48
*`dndDragging` This class will be added to the element while the element is being dragged. It will affect both the element you see while dragging and the source element that stays at it's position. Do not try to hide the source element with this class, because that will abort the drag operation.
@@ -53,8 +54,8 @@ Use the dnd-list attribute to make your list element a dropzone. Usually you wil
53
54
54
55
**Attributes**
55
56
*`dnd-list` Required attribute. The value has to be the array in which the data of the dropped element should be inserted.
56
-
*`dnd-allowed-types` Optional array of allowed item types. When used, only items that had a matching dnd-type attribute will be dropable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
57
-
*`dnd-disable-if` Optional boolean expression. When it evaluates to true, no dropping into the list is possible. Note that this also disables rearranging items inside the list. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
57
+
*`dnd-allowed-types` Optional array of allowed item types. When used, only items that had a matching dnd-type attribute will be dropable. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
58
+
*`dnd-disable-if` Optional boolean expression. When it evaluates to true, no dropping into the list is possible. Note that this also disables rearranging items inside the list. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
58
59
*`dnd-horizontal-list` Optional boolean expression. When it evaluates to true, the positioning algorithm will use the left and right halfs of the list items instead of the upper and lower halfs. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
59
60
*`dnd-external-sources` Optional boolean expression. When it evaluates to true, the list accepts drops from sources outside of the current browser tab. This allows to drag and drop accross different browser tabs. Note that this will allow to drop arbitrary text into the list, thus it is highly recommended to implement the dnd-drop callback to check the incoming element for sanity. Furthermore, the dnd-type of external sources can not be determined, therefore do not rely on restrictions of dnd-allowed-type. Also note that this feature does not work very well in Internet Explorer. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
60
61
@@ -63,13 +64,19 @@ Use the dnd-list attribute to make your list element a dropzone. Usually you wil
63
64
*`event` The original dragover event sent by the browser.
64
65
*`index` The position in the list at which the element would be dropped.
65
66
*`type` The `dnd-type` set on the dnd-draggable, or undefined if unset.
67
+
*`external` Whether the element was dragged from an external source. See `dnd-external-sources`.
*`dnd-drop` Optional expression that is invoked when an element is dropped over the list. If the expression is set, it must return the object that will be inserted into the list. If it returns false, the drop will be aborted and the event is propagated. The following variables will be available:
68
-
*`event` The original drop event sent by the browser.
69
-
*`index` The position in the list at which the element would be dropped.
70
-
*`item` The transferred object.
71
-
*`type` The dnd-type set on the dnd-draggable, or undefined if unset.
*`dnd-drop` Optional expression that is invoked when an element is dropped on the list.
70
+
* The following variables will be available:
71
+
*`event` The original drop event sent by the browser.
72
+
*`index` The position in the list at which the element would be dropped.
73
+
*`item` The transferred object.
74
+
*`type` The dnd-type set on the dnd-draggable, or undefined if unset.
75
+
*`external` Whether the element was dragged from an external source. See `dnd-external-sources`.
76
+
* The return value determines the further handling of the drop:
77
+
*`false` The drop will be canceled and the element won't be inserted.
78
+
*`true` Signalises that the drop is allowed, but the dnd-drop callback will take care of inserting the element.
79
+
* Otherwise: All other return values will be treated as the object to insert into the array. In most cases you simply want to return the `item` parameter, but there are no restrictions on what you can return.
73
80
*`dnd-inserted` Optional expression that is invoked after a drop if the element was actually inserted into the list. The same local variables as for `dnd-drop` will be available. Note that for reorderings inside the same list the old element will still be in the list due to the fact that `dnd-moved` was not called yet. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/advanced)
74
81
75
82
**CSS classes**
@@ -78,13 +85,25 @@ Use the dnd-list attribute to make your list element a dropzone. Usually you wil
78
85
79
86
## dnd-nodrag directive
80
87
81
-
Use the `dnd-nodrag` attribute inside of `dnd-draggable` elements to prevent them from starting drag operations. This is especially useful if you want to use input elements inside of `dnd-draggable` elements or create specific handle elements. [Demo](http://marceljuenemann.github.io/angular-drag-and-drop-lists/demo/#/types)
88
+
Use the `dnd-nodrag` attribute inside of `dnd-draggable` elements to prevent them from starting drag operations. This is especially useful if you want to use input elements inside of `dnd-draggable` elements or create specific handle elements.
89
+
90
+
**Note:** This directive does not work in Internet Explorer 9.
Use the `dnd-handle` directive within a `dnd-nodrag` element in order to allow dragging of that element after all. Therefore, by combining `dnd-nodrag` and `dnd-handle` you can allow `dnd-draggable` elements to only be dragged via specific *handle* elements.
97
+
98
+
**Note:** Internet Explorer will show the handle element as drag image instead of the `dnd-draggable` element. You can work around this by styling the handle element differently when it is being dragged. Use the CSS selector `.dndDragging:not(.dndDraggingSource) [dnd-handle]` for that.
Both the dnd-list and it's children require relative positioning, so that the directive can determine the mouse position relative to the list and thus calculate the correct drop position.
85
104
86
105
<pre>
87
-
ul[dnd-list], ul[dnd-list] > li {
106
+
ul[dnd-list], ul[dnd-list] > li {
88
107
position: relative;
89
108
}
90
109
</pre>
@@ -101,7 +120,7 @@ There are tons of other drag & drop libraries out there, but none of them met my
101
120
If this doesn't fit your requirements, check out one of the other awesome drag & drop libraries:
102
121
103
122
*[angular-ui-tree](https://github.com/JimLiu/angular-ui-tree): Very similar to this library, but does not use the HTML5 API. Therefore you need to write some more markup to see what you are dragging and it will create another DOM node that you have to style. However, if you plan to support touch devices this is probably your best choice.
104
-
*[angular-dragdrop](https://github.com/ganarajpr/angular-dragdrop): One of many libraries with the same name. This one uses the HTML5 API, but if you want to build (nested) sortable lists, you're on your own, because it does not calculate the correct element position for you.
123
+
*[angular-dragdrop](https://github.com/ganarajpr/angular-dragdrop): One of many libraries with the same name. This one uses the HTML5 API, but if you want to build (nested) sortable lists, you're on your own, because it does not calculate the correct element position for you.
0 commit comments