Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
org.webjars.npm:github-com-marceljuenemann-angular-drag-and-drop-lists
Advanced tools
WebJar for 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.
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:
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.
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.
Use the dnd-draggable directive to make your element draggable
Attributes
dnd-draggable
Required attribute. The value has to be an object that represents the data of the element. In case of a drag and drop operation the object will be serialized and unserialized on the receiving end.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. Demodnd-effect-allowed
Use this attribute to limit the operations that can be performed. Options are:
move
The drag operation will move the element. This is the defaultcopy
The drag operation will copy the element. There will be a copy cursor.copyMove
The user can choose between copy and move by pressing the ctrl or shift key.
copy
.link
option, but this library does not actively support it yet, so use it at your own risk.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. Demodnd-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. Demodnd-dragstart
Callback that is invoked when the element was dragged. The original dragstart event will be provided in the local event
variable. Demodnd-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). Demodnd-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). DemoCSS classes
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.dndDraggingSource
This class will be added to the element after the drag operation was started, meaning it only affects the original element that is still at it's source position, and not the "element" that the user is dragging with his mouse pointerUse 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
dnd-list
Required attribute. The value has to be the array in which the data of the dropped element should be inserted.dnd-allowed-types
Optional array of allowed item types. When used, only items that had a matching dnd-type attribute will be dropable. Demodnd-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. Demodnd-horizontal-list
Optional boolean expresssion. 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. Demodnd-dragover
Optional expression that is invoked when an element is dragged over the list. If the expression is set, but does not return true, the element is not allowed to be dropped. The following variables will be available:
event
The original dragover event sent by the browser.index
The position in the list at which the element would be dropped.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 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:
event
The original drop event sent by the browser.index
The position in the list at which the element would be dropped.item
The transferred object.type
The dnd-type set on the dnd-draggable, or undefined if unset.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. DemoCSS classes
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.dndDragover
This class will be added to the list while an element is being dragged over the list.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; }
Since 1.2.0 pointer-events: none
is no longer required
Take a look at the code in the Simple Lists example
Copyright (c) 2014 Marcel Juenemann
FAQs
WebJar for angular-drag-and-drop-lists
We found that org.webjars.npm:github-com-marceljuenemann-angular-drag-and-drop-lists demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.