relateiq/angular-drag-and-drop-lists

Name: angular-drag-and-drop-lists

Owner: SalesforceIQ

Description: Angular directives for sorting nested lists using the HTML5 Drag & Drop API

Created: 2015-11-18 03:03:37.0

Updated: 2015-11-18 03:03:37.0

Pushed: 2015-11-19 22:06:12.0

Homepage: null

Size: 167

Language: HTML

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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.

Demo
Supported browsers

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

Note that touch devices are not supported, because the HTML5 drag & drop standard doesn't cover those. You can try to use a shim for that though.

Download & Installation

Download angular-drag-and-drop-lists.js (or the minified version) and include it in your application. If you use bower, you can of course just add it via bower. Add the dndLists module as dependency to your angular app.

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). Both the dnd-list and it's direct children must have position: relative CSS style, otherwise the positioning algorithm will not be able to determine the correct placeholder position in all browsers.

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. Demo

Required CSS styles

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.

ul[dnd-list], ul[dnd-list] > li { 
    position: relative;
}
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-2015 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


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.