ndn

@ks89/ngx-drag-n-drop

Angular library to enable drag and drop features

Showing:

Popularity

Downloads/wk

17

GitHub Stars

2

Maintenance

Last Commit

2mos ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Built-In

Tree-Shakeable

Yes?

Readme

@ks89/ngx-drag-n-drop

@ks89/ngx-drag-n-drop is an Angular library to add drag and drop features


Based on angular4-drag-drop, but with support for Angular >=7 and other improvements.


npm@latest npm@beta npm@next

Downloads/week Downloads/month Downloads/year

Known Vulnerabilities david-dm Dependencies code style: prettier

Stackblitz AngularStyleGuide

NPMLicense Semver

Do you like @ks89/ngx-drag-n-drop? Please, add a :star: to support this library

Table of Contents

  1. Features
  2. Installation
  3. Choose the version
  4. Usage
  5. News
  6. Contributing
  7. License

💥 Features 💥

  • Angular Module to import this library
  • supports all recommended Angular Compiler Options
  • compliant to Angular Package Format v13 specifications
  • use Semantic versioning 2.0.0 also known as 'semver'
  • official example with angular-cli

📦 Installation 📦

  • npm install --save @ks89/ngx-drag-n-drop

⚠️ Choose the right version ⚠️

@ks89/ngx-drag-n-drop
AngularJSNOT WORKING
Angular 2NOT OFFICIALLY SUPPORTED
Angular 4NOT OFFICIALLY SUPPORTED
Angular 5NOT OFFICIALLY SUPPORTED
Angular 6NOT OFFICIALLY SUPPORTED
Angular 7>= 1.0.0 and <2.0.0
Angular 8>= 1.0.0 and <2.0.0
Angular 9>= 2.0.0 and <3.0.0
Angular 10>= 3.0.0 and <4.0.0
Angular 11>= 3.0.0 and <4.0.0
Angular 12>= 4.0.0
Angular 13>= 5.0.0

Usage

To import the module into a module in which you wish to use the directive on components.

import { DragDropDirectiveModule} from "@ks89/ngx-drag-n-drop";

This module exports two attribute directives, 'DragDirective' and 'DropDirective'. DragDirectve is used with a component from which you want to drag items, while DropDirective is used with the component in which you wish to drop items.

Both accept inputs for CSS class highlighting. If you do not pass a string then highlighting will be ignored. Both will emit the dragged item when it is dropped in the 'DroppableDirective' component or element.

'DragDirective' emits an event when dragging is started.

'DropDirective' emits events when a drag enters a drop element, leaves a drop element, and as stated above when an element is dropped.

DragDirective

<div *ngFor="let item of itemsToDrop" ksDragDirective [draggedItem]='item' [dragHightlight]="'highlight'" (releaseDrop)="releaseDrop($event)" (startDrag)="startDrag(item)">
</div>

'[draggedItem]="item"' Applies the drag directive, and passes it an item.

'[dragHighlight]="'highlight'"' Passes a string to add a css class to the css class list of the element.

'(releaseDrop)="releaseDrop($event)"' Calls a function to act on the dragged item once it is dropped into the drop area.

'(startDrag)="startDrag(item)" Calls a function when the user starts dragging the item.

DropDirectve

<div ksDropDirective (dropEvent)="addDropItem($event)" (dropEventMouse)="dropEventMouse($event) (dragenterEvent)="dragEnter($event)" (dragleaveEvent)="dragLeave()" class="droppable" [dropHighlight]="'highlight'" >
</div>

'ksDropDirective' applies the directive to an element, making it a drop target. '[dropHighlight]="'highlight'"' passes a string to add a css class to the css class list of the element.

'(dropEvent)="addDropItem($event)"' calls a function and passes the dropped item when an item is dropped into the drop element.

'(dropEventMouse)="dropEventMouse($event)"'. dropEventMouse is emitting the html drop event. From this you can get x,y cordinates of the drop etc. If you wish you can use this to get the dropped item as well: let droppedObject = JSON.parse(event.dataTransfer.getData('text')).

'(dragenterEvent)="dragEnter($event)"' calls a function and passes the dragged item when an item is dragged into the drop element.

'(dragleaveEvent)="dragLeave($event)"' calls a function and passes the dragged item when the item is dragged out of the drop element.

🔥 News 🔥

  • 11/04/2021 - 5.0.0 - @ks89/ngx-drag-n-drop - HERE
  • 08/06/2021 - 4.0.0 - @ks89/ngx-drag-n-drop - HERE
  • 13/08/2019 - 3.0.0 - @ks89/ngx-drag-n-drop - HERE
  • 21/02/2019 - 2.0.0 - @ks89/ngx-drag-n-drop - HERE
  • 24/07/2019 - 1.0.1 - @ks89/ngx-drag-n-drop - HERE
  • 24/07/2019 - 1.0.0 - @ks89/ngx-drag-n-drop - HERE

💻 Contributing 💻

Check CONTRIBUTING.md in this repository. To understand how to contribute to an open source project, HERE you can find useful information.

When you create a pull request, please, format your code to be consistent with the existing code. I suggest to use WebStorm as IDE and when you commit don't use a third party software, but the official command line git. In this way, prettier will run using my configuration and it will auto-format the code. If it will fail, add files with git add . again and retry.


©️ License ©️

The MIT License (MIT)

Copyright (c) 2019-2021 Stefano Cappa (Ks89)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


Created by Stefano Cappa

⬆ back to top

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

gridstackBuild interactive dashboards in minutes.
User Rating
4.5/ 5
2
Top Feedback
1Great Documentation
1Highly Customizable
1Hard to Use
GitHub Stars
4K
Weekly Downloads
50K
sortablejsReorderable drag-and-drop lists for modern browsers and touch devices. No jQuery or framework required.
User Rating
4.8/ 5
29
Top Feedback
3Easy to Use
2Great Documentation
2Performant
GitHub Stars
23K
Weekly Downloads
836K
ag
angular-gridster2Angular gridster 2
User Rating
4.0/ 5
2
Top Feedback
N/A
GitHub Stars
1K
Weekly Downloads
70K
nfu
@iplab/ngx-file-uploaddrag and drop file component
User Rating
4.5/ 5
2
Top Feedback
1Easy to Use
1Performant
1Highly Customizable
GitHub Stars
73
Weekly Downloads
5K
ng2-dragulaSimple drag and drop with dragula
User Rating
4.5/ 5
2
Top Feedback
1Great Documentation
1Easy to Use
GitHub Stars
2K
Weekly Downloads
78K
angular-ui-treeA tree component for AngularJS, without jQuery as dependency.
User Rating
4.0/ 5
1
Top Feedback
N/A
GitHub Stars
3K
Weekly Downloads
26K
See 65 Alternatives

Tutorials

No tutorials found
Add a tutorial