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
There are tons of other drag & drop libraries out there, but none of them met my three requirements:
@@ -15,18 +16,17 @@ There are tons of other drag & drop libraries out there, but none of them met my
15
16
16
17
If this doesn't fit your requirements, check out one of the other awesome drag & drop libraries:
17
18
18
-
*[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 and to see what you are dragging it will create another DOM node that you have to style.
19
+
*[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.
19
20
*[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.
Internet Explorer 8 or lower is *not supported*, but all modern browsers are (see changelog for tested versions).
27
+
28
+
Note that *touch devices* are *not supported*, because the HTML5 drag & drop standard doesn't cover those.
29
+
30
30
31
31
## Usage
32
32
@@ -48,6 +48,8 @@ Use the dnd-draggable directive to make your element draggable
48
48
* HTML5 also specifies the `link` option, but this library does not actively support it yet, so use it at your own risk.
49
49
*`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.
50
50
*`dnd-copied` Same as dnd-moved, just that it is called when the element was copied instead of moved.
51
+
*`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).
52
+
*`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)).
51
53
52
54
**CSS classes**
53
55
*`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.
@@ -58,6 +60,8 @@ Use the dnd-list attribute to make your list element a dropzone. Usually you wil
58
60
59
61
**Attributes**
60
62
*`dnd-list` Required attribute. The value has to be the array in which the data of the dropped element should be inserted.
63
+
*`dnd-allowed-types` Optional array of allowed item types. When used, only items that had a matching dnd-type attribute will be dropable.
64
+
*`dnd-disable-if` Optional boolean expresssion. When it evaluates to true, no dropping into the list is possible. Note that this also disables rearranging items inside the list.
61
65
62
66
**CSS classes**
63
67
*`dndPlaceholder` When an element is dragged over the list, a new placeholder child element will be added. This element is of type li and has the class dndPlaceholder set.
0 commit comments