angular-sortablejs
Advanced tools
Comparing version 2.0.0-0 to 2.0.0-1
export * from './src/sortablejs-options'; | ||
export * from './src/sortablejs.directive'; | ||
export * from './src/sortablejs.module'; |
@@ -0,2 +1,3 @@ | ||
export * from './src/sortablejs.directive'; | ||
export * from './src/sortablejs.module'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./src/sortablejs-options"},{"from":"./src/sortablejs.module"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./src/sortablejs-options"},{"from":"./src/sortablejs.module"}]}] | ||
[{"__symbolic":"module","version":3,"metadata":{},"exports":[{"from":"./src/sortablejs-options"},{"from":"./src/sortablejs.directive"},{"from":"./src/sortablejs.module"}]},{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./src/sortablejs-options"},{"from":"./src/sortablejs.directive"},{"from":"./src/sortablejs.module"}]}] |
@@ -9,3 +9,2 @@ import { ElementRef, OnInit, OnChanges, OnDestroy, NgZone, SimpleChanges } from '@angular/core'; | ||
private _sortable; | ||
private onremove; | ||
runInsideAngular: boolean; | ||
@@ -12,0 +11,0 @@ constructor(element: ElementRef, zone: NgZone); |
import { Directive, ElementRef, Input, NgZone } from '@angular/core'; | ||
import { SortablejsModule } from './sortablejs.module'; | ||
import * as Sortable from 'sortablejs/Sortable.min'; | ||
// original library calls the events in unnatural order | ||
// first the item is added, then removed from the previous array | ||
// this is a temporary event to work this around | ||
// as long as only one sortable takes place at a certain time | ||
// this is enough to have a single `global` event | ||
var onremove; | ||
var SortablejsDirective = (function () { | ||
@@ -76,3 +82,3 @@ function SortablejsDirective(element, zone) { | ||
if (_this.bindingEnabled) { | ||
_this.onremove = function (item) { | ||
onremove = function (item) { | ||
if (_this.isItemsFormArray) { | ||
@@ -98,4 +104,4 @@ _this.items.insert(event.newIndex, item); | ||
} | ||
_this.onremove(item); | ||
_this.onremove = null; | ||
onremove(item); | ||
onremove = null; | ||
} | ||
@@ -102,0 +108,0 @@ _this.proxyEvent('onRemove', event); |
{ | ||
"name": "angular-sortablejs", | ||
"version": "2.0.0-0", | ||
"version": "2.0.0-1", | ||
"description": "SortableJS for Angular", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -7,3 +7,3 @@ # angular-sortablejs | ||
Angular 4.x | ||
Angular 4.x (angular-sortablejs@2.x.x; sortablejs must be installed separately) | ||
@@ -14,3 +14,3 @@ ```sh | ||
Angular 2.x: sortablejs is included (changed in 2.0.0) | ||
Angular 2.x (angular-sortablejs@1.x.x; sortablejs is included) | ||
@@ -122,2 +122,34 @@ ```sh | ||
### Tracking lists update events | ||
You can use the options' `onUpdate` method to track the changes (see also *Passing the options* section): | ||
```ts | ||
constructor() { | ||
this.options = { | ||
onUpdate: (event: any) => { | ||
this.postChangesToServer(); | ||
} | ||
}; | ||
} | ||
``` | ||
If you use FormArray you are able to choose a more elegant solution: | ||
```ts | ||
public items = new FormArray([ | ||
new FormControl(1), | ||
new FormControl(2), | ||
new FormControl(3), | ||
]); | ||
constructor() { | ||
this.items.valueChanges.subscribe(() => { | ||
this.postChangesToServer(this.items.value); | ||
}); | ||
} | ||
``` | ||
but note, that here you will be able to take the whole changed array only (no oldIndex / newIndex). | ||
### Updating the options | ||
@@ -124,0 +156,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26080
225
229