Comparing version 2.2.0 to 2.2.1
{ | ||
"name": "ng2-dnd", | ||
"description": "Angular 2 Drag-and-Drop without dependencies", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"scripts": { | ||
@@ -6,0 +6,0 @@ "test": "karma start", |
import { EventEmitter } from '@angular/core'; | ||
import { DragDropConfig } from './dnd.config'; | ||
import { SortableContainer } from './sortable.component'; | ||
export declare class DragDropData { | ||
@@ -18,3 +19,3 @@ dragData: any; | ||
index: number; | ||
sortableData: Array<any>; | ||
sortableContainer: SortableContainer; | ||
isDragged: boolean; | ||
@@ -21,0 +22,0 @@ private _elem; |
@@ -51,3 +51,3 @@ // Copyright (C) 2016 Sergey Akopkokhyants | ||
if (this._sortableDataService.isDragged) { | ||
var item = this._sortableDataService.sortableData[this._sortableDataService.index]; | ||
var item = this._sortableDataService.sortableContainer._sortableData[this._sortableDataService.index]; | ||
// Check does element exist in sortableData of this Container | ||
@@ -58,6 +58,12 @@ if (this._sortableData.indexOf(item) === -1) { | ||
// Remove item from previouse list | ||
this._sortableDataService.sortableData.splice(this._sortableDataService.index, 1); | ||
this._sortableDataService.sortableContainer._sortableData.splice(this._sortableDataService.index, 1); | ||
if (this._sortableDataService.sortableContainer._sortableData.length === 0) { | ||
this._sortableDataService.sortableContainer.dropEnabled = true; | ||
} | ||
// Add item to new list | ||
this._sortableData.unshift(item); | ||
this._sortableDataService.sortableData = this._sortableData; | ||
if (this.dropEnabled) { | ||
this.dropEnabled = false; | ||
} | ||
this._sortableDataService.sortableContainer = this; | ||
this._sortableDataService.index = 0; | ||
@@ -143,3 +149,3 @@ } | ||
this._sortableDataService.isDragged = true; | ||
this._sortableDataService.sortableData = this._sortableContainer.sortableData; | ||
this._sortableDataService.sortableContainer = this._sortableContainer; | ||
this._sortableDataService.index = this.index; | ||
@@ -157,3 +163,3 @@ this._sortableDataService.markSortable(this._elem); | ||
// console.log('_onDragOverCallback. dragging elem with index ' + this.index); | ||
this._sortableDataService.sortableData = this._sortableContainer.sortableData; | ||
this._sortableDataService.sortableContainer = this._sortableContainer; | ||
this._sortableDataService.index = this.index; | ||
@@ -167,3 +173,3 @@ this._sortableDataService.markSortable(this._elem); | ||
this._sortableDataService.isDragged = false; | ||
this._sortableDataService.sortableData = null; | ||
this._sortableDataService.sortableContainer = null; | ||
this._sortableDataService.index = null; | ||
@@ -182,11 +188,17 @@ this._sortableDataService.markSortable(null); | ||
if ((this.index !== this._sortableDataService.index) || | ||
(this._sortableDataService.sortableData !== this._sortableContainer.sortableData)) { | ||
(this._sortableDataService.sortableContainer.sortableData !== this._sortableContainer.sortableData)) { | ||
// console.log('Component._onDragEnterCallback. drag node [' + this.index + '] over node [' + this._sortableDataService.index + ']'); | ||
// Get item | ||
var item = this._sortableDataService.sortableData[this._sortableDataService.index]; | ||
var item = this._sortableDataService.sortableContainer.sortableData[this._sortableDataService.index]; | ||
// Remove item from previouse list | ||
this._sortableDataService.sortableData.splice(this._sortableDataService.index, 1); | ||
this._sortableDataService.sortableContainer.sortableData.splice(this._sortableDataService.index, 1); | ||
if (this._sortableDataService.sortableContainer.sortableData.length === 0) { | ||
this._sortableDataService.sortableContainer.dropEnabled = true; | ||
} | ||
// Add item to new list | ||
this._sortableContainer.sortableData.splice(this.index, 0, item); | ||
this._sortableDataService.sortableData = this._sortableContainer.sortableData; | ||
if (this._sortableContainer.dropEnabled) { | ||
this._sortableContainer.dropEnabled = false; | ||
} | ||
this._sortableDataService.sortableContainer = this._sortableContainer; | ||
this._sortableDataService.index = this.index; | ||
@@ -193,0 +205,0 @@ } |
Sorry, the diff of this file is too big to display
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
253372
2719