Home

Awesome

angular-drag-and-drop-lists

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.

:warning: Discontinuation Notice

This library was built for AngularJS 1.x, which is in maintenance mode. I recommend migrating to Angular and using one of these alternatives:

Let me know if there are other libraries I should add here.

Demo

Supported browsers

Touch devices are not supported, because they do not implement the HTML5 drag & drop standard. However, you can use a shim to make it work on touch devices as well.

Internet Explorer 8 or lower is not supported, but all modern browsers are (see changelog for list of tested browsers).

Download & Installation

dnd-draggable directive

Use the dnd-draggable directive to make your element draggable

Attributes

Callbacks

CSS classes

dnd-list directive

Use the dnd-list attribute to make your list element a dropzone. Usually you will add a single li element as child with the ng-repeat directive. If you don't do that, we will not be able to position the dropped element correctly. If you want your list to be sortable, also add the dnd-draggable directive to your li element(s).

Attributes

Callbacks

CSS classes

dnd-nodrag directive

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.

Note: This directive does not work in Internet Explorer 9.

Demo

dnd-handle directive

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.

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.

Demo

Recommended CSS styles

It is recommended that you apply the following CSS styles:

Note: Previous versions of this directive required postion: relative on certain elements, but this is no longer required.

Why another drag & drop library?

There are tons of other drag & drop libraries out there, but none of them met my three requirements:

If this doesn't fit your requirements, check out one of the other awesome drag & drop libraries:

License

Copyright (c) 2014 Marcel Juenemann

Copyright (c) 2014-2017 Google Inc.

This is not an official Google product (experimental or otherwise), it is just code that happens to be owned by Google.

MIT License