Note: The drag-and-drop directives in angular/cdk are great. Use that if you don't need nested DnD containers. We are investigating using angular/cdk directives internally
To use ngx-dnd in your project install it via npm:
npm i @swimlane/ngx-dnd @swimlane/dragula @types/dragula --save
NgxDnDModule.forRoot()
to your application module.@swimlane/ngx-dnd/release/index.css
.polyfills.ts
file:if (typeof window['global'] === 'undefined') {
window['global'] = window;
}
ngx-dnd
provides a base set of directives to enable drag-and-drop. By default all children of a ngxDroppable
element may be dragged and dropped. Add the ngxDraggable
to restrict drag-and-drop to the parent container. In general prefer using the base directives to the help components introduced later.
<div class="ngx-dnd-container" ngxDroppable>
<div class="ngx-dnd-item" ngxDraggable>Item 1</div>
<div class="ngx-dnd-item" ngxDraggable>Item 2</div>
<div class="ngx-dnd-item" ngxDraggable>Item 3</div>
</div>
Give multiple containers the same dropZone
name to allow drag-and-drop between these containers.
<div class="ngx-dnd-container" ngxDroppable="example">
<div class="ngx-dnd-item" ngxDraggable>Item 1a</div>
<div class="ngx-dnd-item" ngxDraggable>Item 2a</div>
<div class="ngx-dnd-item" ngxDraggable>Item 3a</div>
</div>
<div class="ngx-dnd-container" ngxDroppable="example">
<div class="ngx-dnd-item" ngxDraggable>Item 1b</div>
<div class="ngx-dnd-item" ngxDraggable>Item 2b</div>
<div class="ngx-dnd-item" ngxDraggable>Item 3b</div>
</div>
ngxDraggable
items can be restricted to specific containers:
<div class="ngx-dnd-container" ngxDroppable>
<div class="ngx-dnd-item" [ngxDraggable]="['example-target']">Item 1a</div>
<div class="ngx-dnd-item" [ngxDraggable]="['example-target']">Item 2a</div>
<div class="ngx-dnd-item" [ngxDraggable]="['example-target']">Item 3a</div>
</div>
<div class="ngx-dnd-container" ngxDroppable="example-target">
<div class="ngx-dnd-item" ngxDraggable>Item 1b</div>
<div class="ngx-dnd-item" ngxDraggable>Item 2b</div>
<div class="ngx-dnd-item" ngxDraggable>Item 3b</div>
</div>
ngx-dnd
provides a set of helper components that encapsulates the directives mentioned and adds capability for data driven structures. In general you should prefer directives to components.
orderableLists = [
['Item 1a', 'Item 2a', 'Item 3a'],
['Item 1b', 'Item 2b', 'Item 3b']
];
<ngx-dnd-container [model]="orderableLists"> </ngx-dnd-container>
This component is effectively equivalent to:
<div class="ngx-dnd-container" ngxDroppable [model]="orderableLists">
<div class="ngx-dnd-item" ngxDraggable [model]="item" *ngFor="let item of orderableLists">{{item}}</div>
</div>
Including nested containers:
<ngx-dnd-container [model]="nestedLists"> </ngx-dnd-container>
nestedLists = [
{
label: 'Item 1',
children: []
},
{
label: 'Item 2',
children: [
{
label: 'Item 2a',
children: []
},
{
label: 'Item 2b',
children: []
},
{
label: 'Item 2c',
children: []
}
]
},
{
label: 'Item 3',
children: [
{
label: 'Item 3a',
children: []
},
{
label: 'Item 3b',
children: []
},
{
label: 'Item 3c',
children: []
}
]
}
];
See https://swimlane.github.io/ngx-dnd/ for more lives examples. Demo code is at https://github.com/swimlane/ngx-dnd/tree/master/src/.
git clone git@github.com:swimlane/ngx-dnd.git
cd ngx-dnd
ng build @swimlane/ngx-dnd
ng serve
Run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files.
Run ng build
to build the project. The build artifacts will be stored in the dist/
directory. Use the --prod
flag for a production build.
Run ng test
to execute the unit tests via Karma.
Run ng e2e
to execute the end-to-end tests via Protractor.
To get more help on the Angular CLI use ng help
or go check out the Angular CLI README.
This project uses heff/chg, a simple changelog/release history manager. When contributing to this project please add change notes (manually or using the heff/chg cli) to the ## HEAD (Unreleased)
section.
git checkout master
)git pull
)rm -rf node_modules
npm i
npm run test:ci
)git checkout -b release/X.Y.Z
npm version [<newversion> | major | minor | patch]
package.json
versions and changelog.md
.git push origin HEAD --tags
npm run publish:lib
npm run deploy
ngx-dnd
is a Swimlane open-source project; we believe in giving back to the open-source community by sharing some of the projects we build for our application. Swimlane is an automated cyber security operations and incident response platform that enables cyber security teams to leverage threat intelligence, speed up incident response and automate security operations.
链接:https://github.com/kutlugsahin/ngx-smooth-dnd demo:https://kutlugsahin.github.io/ngx-smooth-dnd/
ngx-weui 是一个使用 Angular 构建的 WeUI 组件。 在线示例以及API文档。
ngx-fastdfs 是 nginx + lua +fastdfs 实现分布式图片实时动态压缩。 install 进入docker目录docker build -t fastdfs:dev . 使用 docker -idt -p 80:80 fastdfs:dev /bin/bash进入容器执行/etc/rc.local 测试 进入容器执行test目录下的./test.sh或者直接执行下面脚本
ngx-markdown ngx-markdown is an Angular library that combines... Marked to parse markdown to HTML Prism.js for language syntax highlight Emoji-Toolkit for emoji support KaTeX for math expression rende
ngx-admin Who uses ngx-admin?| Documentation | Installation Guidelines | Angular templates New! Material theme for ngx-admin Material admin theme is based on the most popular Angular dashboard templat
@sweetalert2/ngx-sweetalert2 Official SweetAlert2 integration for Angular This is not a regular API wrapper for SweetAlert (which already works very well alone), it intends to provide Angular-esque ut
ngx-dropzone A lightweight and highly customizable Angular dropzone component for file uploads. For a demo see DEMO. And the CODE for the demo. Install $ npm install --save ngx-dropzone Usage // in ap