Giter Site home page Giter Site logo

swimlane / ngx-dnd Goto Github PK

View Code? Open in Web Editor NEW
574.0 56.0 140.0 23.5 MB

๐Ÿ•ถ Drag, Drop and Sorting Library for Angular2 and beyond!

Home Page: https://swimlane.github.io/ngx-dnd/

License: MIT License

JavaScript 4.34% TypeScript 76.54% HTML 9.86% CSS 0.83% SCSS 8.43%
ngx drag-and-drop angular angular2 sorting hacktoberfest

ngx-dnd's Introduction

ngx-dnd

Codacy Badge npm downloads

๐Ÿ•ถ Drag, Drop and Sorting Library for Angular6 and beyond!

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

Features

  • Drag and Drop
  • Sorting
  • Events (drag, drop, over, out)
  • Nesting
  • Touch support
  • Templating

Install

To use ngx-dnd in your project install it via npm:

  • npm i @swimlane/ngx-dnd @swimlane/dragula @types/dragula --save
  • Add NgxDnDModule.forRoot() to your application module.
  • If using directives you will need to BYO styles or include @swimlane/ngx-dnd/release/index.css.
  • You may need to add the following to your polyfills.ts file:
if (typeof window['global'] === 'undefined') {
  window['global'] = window;
}

Quick intro and examples

Directives

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>

Components

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

Development

Development server

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.

Build

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.

Running unit tests

Run ng test to execute the unit tests via Karma.

Running end-to-end tests

Run ng e2e to execute the end-to-end tests via Protractor.

Further help

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.

Release

  • Checkout master (git checkout master)
  • Pull master (git pull)
  • Clean and test (Optional)
    • Run rm -rf node_modules
    • Run npm i
    • Run tests (npm run test:ci)
  • Examine CHANGELOG.md to determine next version (X.Y.Z)
  • Run git checkout -b release/X.Y.Z
  • Update version using npm version [<newversion> | major | minor | patch]
    • This will update package.json versions and changelog.md.
  • Run git push origin HEAD --tags
  • Run npm run publish:lib
  • Run npm run deploy
  • Submit PR

Credits

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.

ngx-dnd's People

Contributors

aacebo avatar alexbainter avatar alvaromcsl avatar amcdnl avatar asabit avatar dependabot[bot] avatar earshinov avatar haeminn avatar hypercubed avatar ischultz avatar jakubbialas avatar marjan-georgiev avatar okyrhoe avatar ssuperczynski avatar wandererinvoids avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ngx-dnd's Issues

Multi select and drag

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X ] feature request
[ ] support request => Please do not submit support request here

Is there a way for me to implement multi-select functionality on this? I have a use case where we have hundreds of elements in each container and the user has to drag drop them to the other containers. Bulk operations could prove to be very handy.

Support for Angular 5.0.0

I'm submitting a

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here

(remove/update deprecated code )

No Drag Visuals

Everything appears to be working fine, but the drag-handle, or "ghost" drag element is not appearing on the mouse or touch locations when I start dragging an item. The item just appears below the list and never moves until the drop event is fired.

Am I missing a style include somewhere or something? Thx!

Documentation for directives

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here

Need more documentation to build the model for using with directives, now a lot is shown using the components..

Unexpected token u in JSON at position 0 when using directives and sorting items

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
When you drag & drops an item into an item, everything is fine, also when you drags the dropped item back into the place which has no children, but when you drag & drops an item between two items, so not into an item, I get the following error Unexpected token u in JSON at position 0

Sidenote: when I log 'orderableList' into my controller, I get the originally list, not the one which is shown, how can I get this?

Expected behavior
Drag & drop items into an item + drag & drop item between items should behave correctly

Reproduction of the problem

<div class="ngx-dnd-container"
         ngxDroppable [model]="orderableList" #wtftest>
      <div class="sensor-big-container has-handle"
           ngxDraggable ngxDroppable (drop)="onDropSuccess($event)"
           *ngFor="let sensorGroup of orderableList" fxLayoutGap="14px" [model]="sensor" style="border:1px solid red">
        <div fxFlex class="sensor-container" *ngFor="let sensor of sensorGroup.children" fxLayoutGap="14px">
          <mat-icon svgIcon="sensor"></mat-icon>
          <span fxFlex>{{sensor.name}}</span>
          <mat-icon ngxDragHandle class="draghandle" svgIcon="draghandle"></mat-icon>
        </div>

      </div>
    </div>
this.orderableList = map(this.sensors, ((sensor: MonitorSensor) => {
      return {label: '', children: [sensor]}
    }));

What is the motivation / use case for changing the behavior?
needs to drag an item and drop into it as well

Please tell us about your environment:
OSX

  • Angular version: 5.1.1

  • Browser: [all]

  • Language: [ TypeScript 2.6.2 ]

What is the license on this?

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] licence request
[ ] support request => Please do not submit support request here

What is the license on this? It looks really promising, and I'd really like to use it as it checks a bunch of boxes on a project I'm working on currently, but I can't touch it without an posted open source license (ideally MIT).

Thanks!

On Drop event emitted data should also contains index of child.

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior
Didn't emit newly dropped element index

Expected behavior
It should also emit newly dropped element index

What is the motivation / use case for changing the behavior?
while using on click event in dropZone child elements.

Please tell us about your environment:
Imac, VS code, NPM

  • ngx-charts version: x.x.x
    3.1.0

  • Angular version: 2.x.x
    5.1.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    Typescript

Support Angular 4.4

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior

npm WARN @swimlane/[email protected] requires a peer of @angular/common@~4.3.0 but none was installed.
npm WARN @swimlane/[email protected] requires a peer of @angular/compiler@~4.3.0 but none was installed.
npm WARN @swimlane/[email protected] requires a peer of @angular/core@~4.3.0 but none was installed.
npm WARN @swimlane/[email protected] requires a peer of @angular/platform-browser@~4.3.0 but none was installed.
npm WARN @swimlane/[email protected] requires a peer of @angular/platform-browser-dynamic@~4.3.0 but none was installed.
npm WARN @swimlane/[email protected] requires a peer of [email protected] but none was installed.

Expected behavior
Support angular 4.4

  • ngx-dnd version: 3.0.0
  • Angular version: 4.4.3

Feature request : add click event on ngx-dnd-container

It would be nice to have a click event on container so we can capture the active item.

Here is an example of code from the demo where I added (click) event.

<ngx-dnd-container
            dropZone="builder-target"
            [model]="model.children"
            [removeOnSpill]="true"
            [template]="template"
            [droppableItemClass]="droppableItemClass"
            (click)="setActiveItem($event)"
            (drag)="log($event)"
            (drop)="log($event)"
            (over)="log($event)"
            (out)="log($event)"
            (remove)="log($event)">

Touch support / HTML5 Drag-Drop-API

Hi I'm one of the maintainers of https://github.com/timruffles/ios-html5-drag-drop-shim/tree/rewrite which does a good job polyfilling the HTML5 Drag and Drop API for browsers/devices that don't support it natively. The rewrite is about to be released as stable and I'm using it in production for quite some time now without issues.

I don't know if there are any special cases that your module tries to solve and support but I just wanted to let you know that the mentioned polyfill is able to handle all the touch support needs so your module could rely on the HTML5 Drag and Drop API as the ground to build upon.

Feature - Drag container and drop group of items in another container

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here

I have a use case where the items from one container have to be dropped on another to merge the contents together. I noticed the examples kind of nests the dragged container. This prevents me to move a group of items together in to another container.

Is there any way I can accomplish this with minimal coding.

Thanks
Andy

Allow custom data copy function

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior
Currently when copying a model value, JSON.parse(JSON.stringify(dropElmModel)) is used to copy the value. If the model value has circular references and if you want to manipulate the model data before it is copied it would be nice to provide a function that replaces the JSON copy mechanism.

Expected behavior
ngxDroppable directive has a property copyModelValue or similar where you can provide a custom function to copy a value.

angular cli: AOT does not work

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
when using the angular cli and AOT than the following error appears:

ERROR in ENOENT: no such file or directory, open 'D:\ccviews*******\src\main\ui\node_modules@swimlane\ngx-dnd\release\components\container\container.component.html'

ng build works
ng build --aot leads to the error

Expected behavior
ng build should work with as well as without aot

"dependencies": {
"@ angular/animations": "4.1.2",
"@ angular/common": "4.1.2",
"@ angular/compiler": "4.1.2",
"@ angular/core": "4.1.2",
"@ angular/forms": "4.1.2",
"@ angular/http": "4.1.2",
"@ angular/platform-browser": "4.1.2",
"@ angular/platform-browser-dynamic": "4.1.2",
"@ angular/router": "4.1.2",
"@ ng-bootstrap/ng-bootstrap": "1.0.0-alpha.25",
"@swimlane/ngx-datatable": "9.1.0",
"@swimlane/ngx-dnd": "2.1.2",
"core-js": "2.4.1",
"dragula": "3.7.2",
"file-saver": "1.3.3",
"ng2-dragula": "1.3.1",
"rxjs": "5.4.0",
"zone.js": "0.8.10"
},
"devDependencies": {
"@ angular/cli": "1.0.3",
"@ angular/compiler-cli": "4.1.2",
"@ types/jasmine": "2.5.38",
"@ types/node": "~6.0.60",
"@ types/file-saver": "^0.0.0",
"codelyzer": "2.0.1",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "4.5.1",
"typescript": "2.2.2"
}

How can I make scrolling working when dragging

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[x] support request => Please do not submit support request here

Current behavior
I have lots of draggable items on a page, so the page has a vertical scrollbar. but when I drag an element and move to the top or bottom of the visible area, scrolling doesn't work.
Did anyone solve this problem before? Thanks for your help.

[moves]="false" not working inside *ngFor

I'm submitting a ... (check one with "x")

[X ] bug report => Search GitHub for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior

[moves]="false" is not working with *ngFor

 <div class="ngx-dnd-container" ngxDroppable>
 <!-- [moves]="false" working --> <div class="ngx-dnd-item move-disabled" ngxDraggable [moves]="false">Item 1 - Move Disabled</div>
 			<div *ngFor="let item of items">
 <!--  [moves]="false" not working --> <div class="ngx-dnd-item move-disabled" ngxDraggable [moves]="false">
                                </div>
                         </div>
 </div>

Expected behavior

Reproduction of the problem

What is the motivation/use case for changing the behavior?

Please tell us about your environment:

  • ngx-charts version: x.x.x
  • Angular version: 2.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

Support for Internet Explorer 11

I think there is a bug with the drop event in nested sortable with Internet Explorer 11.

You can reproduce the bug on the demo page ([https://swimlane.github.io/ngx-dnd/]), in the "Nested Sortable" example.
When I try to move the item 3b in first the block (after item 1a), the drop event is not triggered.

Thank you for your help and for your fantastic library!
Elodie

ability to determine drop container location in drop event

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here

Current behavior
As far as I can tell there's no easy way to easily determine which ngx-dnd-container an item has been dropped into, short of using the [model] and doing some fancy parsing. I have a unique id attribute for each ngx-dnd-container and was exploring ways to capture that in the drop event, to no avail.

Expected behavior
Ideally the drop event would have some info on the target e.g. target.id where .id is the id of the drop element.

Reproduction of the problem
See demo multi-list examples with drop event

What is the motivation / use case for changing the behavior?
When I DnD items between lists (ngx-dnd-containers), I need to update the dragged item's listId in the backend, and for that I simply need the group Id information. In this use case, the ngx-dnd-container [model] is generally not needed, since the backend manages all lists and member items.

Please tell us about your environment:

  • ngx-charts version: x.x.x

Using ngx-dnd 3.0.0

  • Angular version: 2.x.x

using ng 4.4.6

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Have tested with Chrome latest

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    ES6 / ES5

Cancel after drop?

Hi, are there any plans or documentation to be able to cancel an ongoing drop from code?

(e.g when the underlying logic that handles the drop event goes wrong, and you want to put the item back to its original place/container)

How To Add Templates

Could you please show how to template a section or a draggle item.
I would live to add some styling inputs buttons but not sure how.
Thanks

Feature: disable dnd-container

I'm submitting a ...

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Sorry, will will not be able to answer every support request.  Please consider other venues for support requests

Hi, is there a way of disabling dnd-container so it won't allow dropping items anymore?

DragulaOptions

Very important feature create Input() for dragula options (its commended right now). I need set a mirrorContainer, but cannot do this.

Form Array sortable with ngx-dnd

I try to play with form Array in Angular5.
I create a list of forms with form Array and i want the use can reorganize them with ngx-dnd

// ... into the forms : my formArray "lines" (formData is a getter which returns this.form.get('lines');
<div class="ngx-dnd-container" ngxDroppable [model]="formData.controls">
    <div class="ngx-dnd-item" ngxDraggable [model]="line" formArrayName="lines" *ngFor="let line of formData.controls; let i = index;">
        <div [formGroupName]="i">
            <textarea formControlName="linedescription"></textarea>
        </div>
    </div>
</div>

TEST HERE : https://angular-xqhjug.stackblitz.io

The problem is :

  • This code works fine IF the user type into textarea AFTER he drags and drop
  • This code doesn't work IF the user JUST drag and drop (in this case my form Array "lines" is the same that before drag and drop to change order)

Questions :
1 Do you know how to use correctly ng-dnd with form Array (i have the index of form in array in my template)
2 Can i use a "callback method" of ng-dnd in my Component ? (to execute something after "drop")

Thanks.
Fred from Paris, France

Support a trackBy function for performance

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here

Current behavior
I'm currently using the ngx-dnd with some extra filters and data which is loaded / triggered by an updated [BehaviorSubject] (Which means a total repaint/rebuilt/re-rendering every time)

The items have a lot of info (html, data, etc)

<ngx-dnd-container  [model]="availableBookItems$ | async | filterBy: filter | orderBy: 'book.displayName '"
        [dropZones]="['restricted-target']">
        <md-accordion class="__playlistitems-container">
          <ng-template let-availableBookItem="model">
            <md-expansion-panel class="u-movable" hideToggle="true">
              <md-expansion-panel-header expandedHeight="88px" collapsedHeight="72px">
                <md-panel-title fxFlex="60">
                  <bsm-availablebook-panel-title [book]="availableBookItem.book"></bsm-availablebook-panel-title>
                </md-panel-title>
                <md-panel-description fxFlexLayout fxLayoutAlign="end center" class=" u-text-align-right">
                  <span *ngIf="availableBookItem.book.collectionName" class="__subheader">
                  {{ availableBookItem.book.collectionName }}
                </span>
                  <button md-icon-button color="primary" (click)="addToPlaylist(availableBookItem); removeFromAvailable(availableBookItem)"
                    mdTooltip="Voeg boek toe aan de afspeellijst">
                  <md-icon>playlist_add</md-icon>
                </button>
                </md-panel-description>
              </md-expansion-panel-header>
              <!-- Panel content -->
              <bsm-book-panel-content [book]="availableBookItem.book"></bsm-book-panel-content>
            </md-expansion-panel>
          </ng-template>
        </md-accordion>
      </ngx-dnd-container>

It would be great if we could provide a/the trackBy function, to improve the performance

Please tell us about your environment:

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / โ–ณ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
@angular/cli: 1.4.3
node: 8.1.4
os: win32 x64
@angular/animations: 4.4.3
@angular/cdk: 2.0.0-beta.10-1b6b270
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/material: 2.0.0-beta.10-1b6b270
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/platform-server: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.4.3
typescript: 2.5.2
  • ngx-charts version: x.x.x

"@swimlane/ngx-dnd": "~3.0.0",

Error if using AOT: "Cannot read property 'set' of undefined"

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Sorry, will will not be able to answer every support request.  Please consider other venues for support requests

Current behavior
This is my component code:

<div ngxDroppable="'page'" [model]="newForm.controls">
      <div *ngFor="let control of newForm.controls; index as i; last as isLast" ngxDraggable="['page']" [model]="control">
        <iqz-saf-form-section-edit [allControls]="newForm.controls" [section]="control" [totalSections]="newForm.controls.length" [currentSectionIndex]="i" (actionClicked)="handleSectionAction($event, i)"></iqz-saf-form-section-edit>
        <div *ngIf="!isLast" class="field">
          <div class="control">
            <input class="is-checkradio is-small is-rtl" type="checkbox" id="{{'pagebreak_' + i}}" [value]="i" (change)="togglePagebreak(i)" [checked]="newForm.pageBreakIndices.indexOf(i) != -1" />
            <label for="{{'pagebreak_' + i}}">Break to new page here</label>
          </div>
        </div>
      </div>
    </div>

The drag and drop feature works totally fine when using JIT compilation. However, if I compile via AOT, I get the following error in the browser console when visiting the page:

ERROR TypeError: Cannot read property 'set' of undefined
    at DrakeStoreService.register (drake-store.service.js:24)
    at DroppableDirective.ngOnInit (ngx-droppable.directive.js:50)
    at checkAndUpdateDirectiveInline (core.js:12351)
    at checkAndUpdateNodeInline (core.js:13878)
    at checkAndUpdateNode (core.js:13821)
    at debugCheckAndUpdateNode (core.js:14714)
    at debugCheckDirectivesFn (core.js:14655)
    at Object.eval [as updateDirectives] (new-intake-form.component.html:33)
    at Object.debugUpdateDirectives [as updateDirectives] (core.js:14640)
    at checkAndUpdateView (core.js:13787)

Expected behavior
AOT should work the same way as JIT.

Please tell us about your environment:
Angular version: 5.2.0
Typescript version: 2.4.2

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    all

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    all

ngxDragHandle with [ngxDraggable]

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

( maybe is a support request ? =\ )

Current behavior

ngxDragHandle doesn't work if the 'ngDraggable' directive is wrapped in brackets.
Expected behavior

same behavior as if 'ngDraggable' didn't have brackets.

Reproduction of the problem

Here a small example: https://stackblitz.com/edit/angular-6esdtm
I can drag and drop DIV while I used ngxDragHandle

What is the motivation / use case for changing the behavior?

To make my component reusable with another name zone:
I pass the names of the zones by 'Input ()' and sometime I use conditions in '[ngxDraggable]'.

Please tell us about your environment:

  • Angular version: 5.2.5
  • Browser: [Chrome XX]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

angular cli Error

Angular CLI 4.0.2 and 4.0.3

ng serve => error
ERROR in BrowserAnimationsModule is not an NgModule

ng serve --aot => error
ERROR in Unexpected value 'BrowserAnimationsModule in /node_modules/@swimlane/ngx-dnd/release/node_modules/@angular/platform-browser/animations/index.d.ts' imported by the module 'NgxDnDModule in /node_modules/@swimlane/ngx-dnd/release/ngx-dnd.module.d.ts'. Please add a @NgModule annotation.

What should I do?

===================================================
**package.json**

"dependencies": {
    "@angular/animations": "^4.0.2",
    "@angular/common": "^4.0.2",
    "@angular/compiler": "^4.0.2",
    "@angular/core": "^4.0.2",
    "@angular/flex-layout": "^2.0.0-beta.7",
    "@angular/forms": "^4.0.2",
    "@angular/http": "^4.0.2",
    "@angular/platform-browser": "^4.0.2",
    "@angular/platform-browser-dynamic": "^4.0.2",
    "@angular/router": "^4.0.2",
    "core-js": "2.4.1",
    "rxjs": "^5.1.0",
    "zone.js": "^0.8.4",
    "@swimlane/ngx-dnd": "^2.0.1",
    "@swimlane/ngx-ui": "^14.2.4",
    "ng2-cookies": "^1.0.11",
    "ng2-webstorage": "^1.6.2",
    "jquery": "^3.1.1",
    "toastr": "^2.1.2"
  },
  "devDependencies": {
    "@angular/cli": "1.0.0",
    "@angular/compiler-cli": "^4.0.2",
    "@angular/platform-server": "^4.0.2",
    "@types/jasmine": "^2.5.38",
    "@types/node": "^7.0.5",
    "@types/jquery": "^2.0.40",
    "@types/toastr": "^2.1.33",
    "codelyzer": "~2.0.0",
    "jasmine-core": "~2.5.2",
    "jasmine-spec-reporter": "~3.2.0",
    "karma": "~1.4.1",
    "karma-chrome-launcher": "~2.0.0",
    "karma-cli": "~1.0.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "karma-coverage-istanbul-reporter": "0.2.0",
    "protractor": "~5.1.0",
    "ts-node": "~2.0.0",
    "tslint": "~4.5.0",
    "typescript": "~2.2.0"
  }

dragging event in ngx-dnd-container

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here

Browser: [all]
Language: [all]

I'm trying to implement a feature that would activate scroll of the container that holds the "ngx-dnd". For this I need event like "dragging" in the "ngx-dnd-container". This should trigger on mousemove event while dragging.

Using the library with Angular 5. Works great on Chrome & Edge browsers but cannot get it to work on internet explorer. It drags but does not drop. Can it be made to work on internet explorer?

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Sorry, we will not be able to answer every support request.  Please consider other venues for support requests

Current behavior

Expected behavior

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-charts version: x.x.x
  • Angular version: 2.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

JSON error when using directives for copying objects

I'm submitting a ... (check one with "x")

[ x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

I am using dnd in an environment like your "Builder Demo" and recently followed your recommendation to move from components to directives.

Current behavior
When dragging an element from one container to another I get the following error:
ERROR SyntaxError: Unexpected token u in JSON at position 0

Expected behavior
I expect the same, working functionality like in component usage.

Reproduction of the problem
See
https://github.com/cedWetzel/dng-example/blob/master/src/app/app.component.html

And maybe #19
What is the motivation / use case for changing the behavior?
This should just work because ngx-dnd is just awesome.

Please tell us about your environment:

node: 7.4.0
os: darwin x64
@angular/animations: 4.4.6
@angular/common: 4.4.6
@angular/compiler: 4.4.6
@angular/core: 4.4.6
@angular/forms: 4.4.6
@angular/http: 4.4.6
@angular/platform-browser: 4.4.6
@angular/platform-browser-dynamic: 4.4.6
@angular/router: 4.4.6
@angular/cli: 1.4.7
@angular/compiler-cli: 4.4.6
@angular/language-service: 4.4.6
typescript: 2.3.4
  • ngx-dnd version: 3.1.0

  • Angular version: 4.4.6

  • Browser: [all ]

EDIT:
My error, will explain my errors, maybe it will be helpful for others.

Include in the docs the need to add reference to @swimlane/ng-dnd/release/index.css

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X ] feature request
[ ] support request => Please do not submit support request here

Current behavior
Following the documentation, drag and drop works but looks nothing like the demos, with the currently dragging element showing up at the bottom of the container and not sticking to the pointer.

Expected behavior
I expect the results from the demo when I follow the installation and code samples.

Reproduction of the problem
Start a fresh angular project, create a feature module using ngx-dnd, install following the documentation and use the demo code.

What is the motivation / use case for changing the behavior?
The documentation needs to give ALL of the steps needed to install the module and have it work correctly.

Please tell us about your environment:

I'm using VSCode running on Windows 10 for development.

  • ngx-charts version: x.x.x
  • Angular version: 4.3.4
  • Browser: all
  • Language: TypeScript 2.4.2

Drag and drop bugs in horizontal layout

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior

avatar
Expected behavior

Insert to the end

[question] Events when using directive, not component

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request
[x] support request => Sorry, will will not be able to answer every support request.  Please consider other venues for support requests

Is it possible to listen on events:

(drag)="log($event)"
(drop)="log($event)"
(over)="log($event)"
(out)="log($event)"
(remove)="log($event)"

when using ngxDraggable directive instead of <ngx-dnd-container> component?

Current behaviour

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

Expected behavior
?
Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • ngx-dnd version: 3.1.0

  • Angular version: 5.2.0

  • Browser: Chrome 64

  • Language:

there is no 'swimlane/ngx-dnd' npm package in the registry.

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
when I install the package. A npm err occured.
the buglog like this

D:\project>npm i @swimlane/nax-dnd --save
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_global\\node_modules\\npm\
\bin\\npm-cli.js" "i" "@swimlane/nax-dnd" "--save"
npm ERR! node v6.9.5
npm ERR! npm  v4.0.3
npm ERR! code E404

npm ERR! 404 Not found : @swimlane/nax-dnd
npm ERR! 404
npm ERR! 404  '@swimlane/nax-dnd' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR!     D:\project\test\wiss\npm-debug.log

Support Angular 4.2

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior

warning "@swimlane/[email protected]" has incorrect peer dependency "@angular/common@~4.0.2".
warning "@swimlane/[email protected]" has incorrect peer dependency "@angular/compiler@~4.0.2".
warning "@swimlane/[email protected]" has incorrect peer dependency "@angular/core@~4.0.2".
warning "@swimlane/[email protected]" has incorrect peer dependency "@angular/platform-browser@~4.0.2".
warning "@swimlane/[email protected]" has incorrect peer dependency "@angular/platform-browser-dynamic@~4.0.2".
warning "@swimlane/[email protected]" has incorrect peer dependency "[email protected]".
warning "@swimlane/[email protected]" has incorrect peer dependency "zone.js@^0.7.6".

Expected behavior
Support angular 4.2

  • ngx-dnd version: 2.1.2

  • Angular version: 4.2

Hi, I need one help. Can you please help me to convert the following ngx template to ngx directive? Thanks in advance. I am getting JSON parsing error .

 <div class="builder-source" fxFlex="20%">
          <h4>Source</h4>

          <ngx-dnd-container
            class="root-container"
            [model]="sourceBuilderTools"
            [dropZones]="['builder-target']"
            [copy]="true"
            [droppableItemClass]="droppableItemClass"
            (drag)="builderDrag($event)">

            <ng-template let-item="model">
              <ngx-icon [fontIcon]="item.icon"></ngx-icon>
              {{item.name}}
            </ng-template>
          </ngx-dnd-container>

        </div>
        <div class="builder-target" fxFlex="60%">
          <h4>Target</h4>

          <ngx-dnd-container
            class="root-container"
            [model]="targetBuilderTools"
            dropZone="builder-target"
            [removeOnSpill]="true"
            [droppableItemClass]="droppableItemClass"
            (drag)="log($event)"
            (drop)="log($event)"
            (over)="log($event)"
            (out)="log($event)"
            (remove)="log($event)">

            <ng-template let-model="model" let-template="template">
              <div [ngSwitch]="model.inputType">
                <div *ngSwitchCase="'section'">
                   <ngx-section class="shadow" [sectionTitle]="model.name">
                     <ngx-dnd-container
                       dropZone="builder-target"
                       [model]="model.children"
                       [removeOnSpill]="true"
                       [template]="template"
                       [droppableItemClass]="droppableItemClass"
                       (drag)="log($event)"
                       (drop)="log($event)"
                       (over)="log($event)"
                       (out)="log($event)"
                       (remove)="log($event)">
                     </ngx-dnd-container>
                   </ngx-section>
                </div>
                <div *ngSwitchDefault>
                  <ngx-input
                    [type]="model.inputType"
                    [hint]="model.name"
                    [autofocus]="false"
                    [ngModel]="model.data">
                  </ngx-input>
                </div>
              </div>
            </ng-template>
          </ngx-dnd-container>
        </div>
        <div fxFlex>
          <h3>Model</h3>
          <pre><code>{{targetBuilderTools | json}}</code></pre>
        </div>
      </div>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.