NgReorder
This module provides a way to sort elements within a list by using drag-n-drop interface without any restrictions by direction.
see live example
Instalation
npm install ng-reorder
API
DragUnitDirective
Dragable element
selector: dragUnit
Inputs
Input | Type | Default value | Description |
---|---|---|---|
disabled | boolean | false |
An element will not response for dragging while this property it's true |
Outputs
Output | Type | Description |
---|---|---|
unitTaken: | EventEmitter<UnitTaken> | Emits when the dragging sequence successfully started and an element is taken |
unitMoved: | EventEmitter<UnitMoved> | Emits when an element is moved on a page while user is dragging it |
unitReleased: | EventEmitter<UnitReleased> | Emits when an element is being released |
DragCollectionDirective
Collection for dragable elements
selector: dragCollection
Inputs
Input | Type | Default value | Description |
---|---|---|---|
disabled | boolean | false |
Dragging sequence will not starts at all when true |
Outputs
Output | Type | Description |
---|---|---|
dropCompleted | EventEmitter<CollectionSorted> | Emits when drag-n-drop sequence is totaly comleted |
DragHandleDirective
An element which will start drag sequence in case whether you don't want to use the entire field of DragUnitDirective
parent
selector: dragHandle
DragRegectorDirective
An element which will not start drag sequence in case whether you need to exclude some element from that(buttons, inputs, ect.)
selector: dragRejector
Interfaces
UnitTaken
Data | Type | Description |
---|---|---|
element | DragUnitDirective | Source element |
event | MouseEvent | TouchEvent | Native event |
UnitMoved
Data | Type | Description |
---|---|---|
element | DragUnitDirective | Source element |
distance | Point | Distance in pixels from the position where the source element was taken |
event | MouseEvent | TouchEvent | Native event |
UnitReleased
Data | Type | Description |
---|---|---|
element | DragUnitDirective | Source element |
event | MouseEvent | TouchEvent | Native event |
CollectionSorted
Data | Type | Description |
---|---|---|
collection | DragCollectionDirective | Collection which contain the source element |
element | DragUnitDirective | Source element |
previousIndex | number | Origin index of the element in the collection |
currentIndex | number | New index of the element where it was moved to within the collection |
Point
Data | Type | Description |
---|---|---|
x | number | Pixel's amount along X-axis |
y | number | Pixel's amount along Y-axis |
Usage
- Register
NgReorderModule
in your app module or any module you'd like
;;;;
;;
- Use
dragCollection
directive for wrapper of collection of your elements (ul
,ol
, or justdiv
for instance)
add remove {{item}} <!-- THIS ELEMENT WILL NOT RESPOND FOR DRAG-N-DROP -->
- Style your elements
Credits
This project is based on Angular's Drag-and-drop module and I really want to thanks everyone Angular team member for creating this awesome framework.