Skip to content

Commit

Permalink
feat(): Migrated on Angular 2.0.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
akserg committed May 5, 2016
1 parent 610f677 commit 244398e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 8 deletions.
7 changes: 5 additions & 2 deletions bundles/ng2-dnd.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ System.registerDynamic("src/dnd.draggable", ["angular2/core", "./dnd.component",
configurable: true
});
DraggableComponent.prototype._onDragStartCallback = function(event) {
this._dragDropService.isDragged = true;
this._dragDropService.dragData = this.dragData;
this._dragDropService.onDragSuccessCallback = this.onDragSuccessCallback;
this._elem.classList.add(this._config.onDragStartClass);
};
DraggableComponent.prototype._onDragEndCallback = function(event) {
this._dragDropService.isDragged = false;
this._dragDropService.dragData = null;
this._dragDropService.onDragSuccessCallback = null;
this._elem.classList.remove(this._config.onDragStartClass);
Expand Down Expand Up @@ -312,6 +314,7 @@ System.registerDynamic("src/dnd.sortable", ["angular2/core", "./dnd.component",
this._sortableDataService.sortableData = this._sortableContainer.sortableData;
this._sortableDataService.index = this.index;
this._sortableDataService.markSortable(this._elem);
this._dragDropService.isDragged = true;
this._dragDropService.dragData = this.dragData;
this._dragDropService.onDragSuccessCallback = this.onDragSuccessCallback;
};
Expand All @@ -327,6 +330,7 @@ System.registerDynamic("src/dnd.sortable", ["angular2/core", "./dnd.component",
this._sortableDataService.sortableData = null;
this._sortableDataService.index = null;
this._sortableDataService.markSortable(null);
this._dragDropService.isDragged = false;
this._dragDropService.dragData = null;
this._dragDropService.onDragSuccessCallback = null;
this.onDragEndCallback.emit(this._dragDropService.dragData);
Expand Down Expand Up @@ -546,7 +550,6 @@ System.registerDynamic("src/dnd.component", ["angular2/core", "./dnd.config", ".
this._elem.ondragstart = function(event) {
_this._onDragStart(event);
if (event.dataTransfer != null) {
console.log('effectAllowed', _this.effectAllowed);
event.dataTransfer.effectAllowed = _this.effectAllowed || _this._config.dragEffect.name;
event.dataTransfer.setData('text', '');
if (_this._config.dragImage != null) {
Expand Down Expand Up @@ -611,7 +614,7 @@ System.registerDynamic("src/dnd.component", ["angular2/core", "./dnd.config", ".
};
Object.defineProperty(AbstractComponent.prototype, "_isDropAllowed", {
get: function() {
if (this.dropEnabled) {
if (this._dragDropService.isDragged && this.dropEnabled) {
if (this.dropZones.length === 0 && this._dragDropService.allowedDropZones.length === 0) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion bundles/ng2-dnd.min.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@
"url": "https://github.com/akserg/ng2-dnd/issues"
},
"homepage": "https://github.com/akserg/ng2-dnd#readme",
"devDependencies": {
"angular2": "~2.0.0-beta.17",
"dependencies": {
"@angular/common": "^2.0.0-rc.1",
"@angular/compiler": "^2.0.0-rc.1",
"@angular/core": "^2.0.0-rc.1",
"@angular/platform-browser": "^2.0.0-rc.1",
"@angular/platform-browser-dynamic": "^2.0.0-rc.1",
"es6-promise": "~3.1.2",
"es6-shim": "~0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.6",
"zone.js": "~0.6.12",
"zone.js": "~0.6.12"
},
"devDependencies": {
"cz-conventional-changelog": "^1.1.5",
"jasmine-core": "~2.3.4",
"karma": "~0.13.15",
Expand Down
3 changes: 1 addition & 2 deletions src/dnd.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export abstract class AbstractComponent {
this._onDragStart(event);
//
if (event.dataTransfer != null) {
console.log('effectAllowed', this.effectAllowed);
event.dataTransfer.effectAllowed = this.effectAllowed || this._config.dragEffect.name;
event.dataTransfer.setData('text', '');

Expand Down Expand Up @@ -146,7 +145,7 @@ export abstract class AbstractComponent {
}

private get _isDropAllowed(): boolean {
if (this.dropEnabled) {
if (this._dragDropService.isDragged && this.dropEnabled) {
if (this.dropZones.length === 0 && this._dragDropService.allowedDropZones.length === 0) {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/dnd.draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ export class DraggableComponent extends AbstractComponent {
}

_onDragStartCallback(event: Event) {
this._dragDropService.isDragged = true;
this._dragDropService.dragData = this.dragData;
this._dragDropService.onDragSuccessCallback = this.onDragSuccessCallback;
this._elem.classList.add(this._config.onDragStartClass);
}

_onDragEndCallback(event: Event) {
this._dragDropService.isDragged = false;
this._dragDropService.dragData = null;
this._dragDropService.onDragSuccessCallback = null;
this._elem.classList.remove(this._config.onDragStartClass);
Expand Down
1 change: 1 addition & 0 deletions src/dnd.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class DragDropService {
allowedDropZones: Array<string> = [];
onDragSuccessCallback: EventEmitter<any>;
dragData: any;
isDragged: boolean;
}

@Injectable()
Expand Down
2 changes: 2 additions & 0 deletions src/dnd.sortable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export class SortableComponent extends AbstractComponent {
this._sortableDataService.index = this.index;
this._sortableDataService.markSortable(this._elem);
// Add dragData
this._dragDropService.isDragged = true;
this._dragDropService.dragData = this.dragData;
this._dragDropService.onDragSuccessCallback = this.onDragSuccessCallback;
//
Expand All @@ -132,6 +133,7 @@ export class SortableComponent extends AbstractComponent {
this._sortableDataService.index = null;
this._sortableDataService.markSortable(null);
// Add dragGata
this._dragDropService.isDragged = false;
this._dragDropService.dragData = null;
this._dragDropService.onDragSuccessCallback = null;
//
Expand Down

0 comments on commit 244398e

Please sign in to comment.