Skip to content
This repository was archived by the owner on Mar 5, 2024. It is now read-only.

Commit 0bc89b0

Browse files
committed
Update to fix issue with ngFor not working correctly. Change to use .emit rather than .next for EventEmitter. Correctly implement OnDestroy method. Closes #33
1 parent d9171af commit 0bc89b0

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed

gulpfile.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ var PATHS = {
3030
'bower_components/bootstrap/dist/css/bootstrap.min.css',
3131
'bower_components/bootstrap/dist/css/bootstrap-theme.min.css',
3232
'node_modules/angular2/bundles/angular2.min.js',
33+
'node_modules/angular2/bundles/angular2-polyfills.min.js',
3334
'node_modules/systemjs/dist/system.js',
3435
'node_modules/systemjs/dist/system-polyfills.js',
3536
'node_modules/es6-shim/es6-shim.min.js',
36-
'node_modules/reflect-metadata/Reflect.js'
37+
'node_modules/reflect-metadata/Reflect.js',
38+
'node_modules/rxjs/bundles/Rx.min.js'
3739
],
3840
rx: 'node_modules/rxjs/**/*.js',
3941
typings: [

src/NgGrid.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ElementRef, Renderer, EventEmitter, DynamicComponentLoader, KeyValueDiffers, OnInit, DoCheck } from 'angular2/core';
1+
import { ElementRef, Renderer, EventEmitter, DynamicComponentLoader, KeyValueDiffers, OnInit, OnDestroy, DoCheck } from 'angular2/core';
22
export declare class NgGrid implements OnInit, DoCheck {
33
private _differs;
44
private _ngEl;
@@ -95,7 +95,7 @@ export declare class NgGrid implements OnInit, DoCheck {
9595
private _getItemFromPosition(position);
9696
private _createPlaceholder(pos, dims);
9797
}
98-
export declare class NgGridItem implements OnInit {
98+
export declare class NgGridItem implements OnInit, OnDestroy {
9999
private _ngEl;
100100
private _renderer;
101101
private _ngGrid;
@@ -137,7 +137,7 @@ export declare class NgGridItem implements OnInit {
137137
canDrag(e: any): boolean;
138138
canResize(e: any): string;
139139
onMouseMove(e: any): void;
140-
onDestroy(): void;
140+
ngOnDestroy(): void;
141141
getElement(): ElementRef;
142142
getDragHandle(): string;
143143
getResizeHandle(): string;

src/NgGrid.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, View, Directive, ElementRef, Renderer, EventEmitter, DynamicComponentLoader, Host, ViewEncapsulation, Type, ComponentRef, KeyValueDiffer, KeyValueDiffers, OnInit, DoCheck } from 'angular2/core';
1+
import { Component, View, Directive, ElementRef, Renderer, EventEmitter, DynamicComponentLoader, Host, ViewEncapsulation, Type, ComponentRef, KeyValueDiffer, KeyValueDiffers, OnInit, OnDestroy, DoCheck } from 'angular2/core';
22

33
@Directive({
44
selector: '[ngGrid]',
@@ -372,8 +372,8 @@ export class NgGrid implements OnInit, DoCheck {
372372
this._createPlaceholder(item.getGridPosition(), item.getSize());
373373
this.isResizing = true;
374374

375-
this.resizeStart.next(item);
376-
item.resizeStart.next(item.getDimensions());
375+
this.resizeStart.emit(item);
376+
item.resizeStart.emit(item.getDimensions());
377377
}
378378
}
379379

@@ -391,8 +391,8 @@ export class NgGrid implements OnInit, DoCheck {
391391
this._createPlaceholder(item.getGridPosition(), item.getSize());
392392
this.isDragging = true;
393393

394-
this.dragStart.next(item);
395-
item.dragStart.next(item.getPosition());
394+
this.dragStart.emit(item);
395+
item.dragStart.emit(item.getPosition());
396396
}
397397
}
398398

@@ -444,8 +444,8 @@ export class NgGrid implements OnInit, DoCheck {
444444
this._draggingItem.setPosition(newL, newT);
445445
}
446446

447-
this.drag.next(this._draggingItem);
448-
this._draggingItem.drag.next(this._draggingItem.getPosition());
447+
this.drag.emit(this._draggingItem);
448+
this._draggingItem.drag.emit(this._draggingItem.getPosition());
449449
}
450450
}
451451

@@ -490,8 +490,8 @@ export class NgGrid implements OnInit, DoCheck {
490490
if (this._resizeDirection == 'height') bigGrid.x = iGridPos.col + itemSize.x;
491491
if (this._resizeDirection == 'width') bigGrid.y = iGridPos.row + itemSize.y;
492492

493-
this.resize.next(this._resizingItem);
494-
this._resizingItem.resize.next(this._resizingItem.getDimensions());
493+
this.resize.emit(this._resizingItem);
494+
this._resizingItem.resize.emit(this._resizingItem.getDimensions());
495495
}
496496
}
497497

@@ -519,8 +519,8 @@ export class NgGrid implements OnInit, DoCheck {
519519
this._cascadeGrid();
520520

521521
this._draggingItem.stopMoving();
522-
this._draggingItem.dragStop.next(this._draggingItem.getPosition);
523-
this.dragStop.next(this._draggingItem);
522+
this._draggingItem.dragStop.emit(this._draggingItem.getPosition);
523+
this.dragStop.emit(this._draggingItem);
524524
this._draggingItem = null;
525525
this._posOffset = null;
526526
this._placeholderRef.dispose();
@@ -539,8 +539,8 @@ export class NgGrid implements OnInit, DoCheck {
539539
this._cascadeGrid();
540540

541541
this._resizingItem.stopMoving();
542-
this._resizingItem.resizeStop.next(this._resizingItem.getDimensions());
543-
this.resizeStop.next(this._resizingItem);
542+
this._resizingItem.resizeStop.emit(this._resizingItem.getDimensions());
543+
this.resizeStop.emit(this._resizingItem);
544544
this._resizingItem = null;
545545
this._resizeDirection = null;
546546
this._placeholderRef.dispose();
@@ -909,7 +909,7 @@ export class NgGrid implements OnInit, DoCheck {
909909
inputs: [ 'config: ngGridItem', 'gridPosition: ngGridPosition', 'gridSize: ngGridSize' ],
910910
outputs: ['itemChange', 'dragStart', 'drag', 'dragStop', 'resizeStart', 'resize', 'resizeStop']
911911
})
912-
export class NgGridItem implements OnInit {
912+
export class NgGridItem implements OnInit, OnDestroy {
913913
// Event Emitters
914914
public itemChange: EventEmitter<any> = new EventEmitter();
915915
public dragStart: EventEmitter<any> = new EventEmitter();
@@ -1044,7 +1044,7 @@ export class NgGridItem implements OnInit {
10441044
}
10451045
}
10461046

1047-
public onDestroy(): void {
1047+
public ngOnDestroy(): void {
10481048
if (this._added) this._ngGrid.removeItem(this);
10491049
}
10501050

@@ -1100,7 +1100,7 @@ export class NgGridItem implements OnInit {
11001100
this.gridSize = { 'x': this._sizex, 'y': this._sizey };
11011101
this._recalculateDimensions();
11021102

1103-
this.itemChange.next({'col': this._col, 'row': this._row, 'sizex': this._sizex, 'sizey': this._sizey});
1103+
this.itemChange.emit({'col': this._col, 'row': this._row, 'sizex': this._sizex, 'sizey': this._sizey});
11041104
}
11051105

11061106
public setGridPosition(col: number, row: number): void {
@@ -1110,7 +1110,7 @@ export class NgGridItem implements OnInit {
11101110

11111111
this._recalculatePosition();
11121112

1113-
this.itemChange.next({'col': this._col, 'row': this._row, 'sizex': this._sizex, 'sizey': this._sizey});
1113+
this.itemChange.emit({'col': this._col, 'row': this._row, 'sizex': this._sizex, 'sizey': this._sizey});
11141114
}
11151115

11161116
public setPosition(x: number, y: number): void {

src/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, View, Self, Query, QueryList, ViewEncapsulation, enableProdMode } from 'angular2/core';
1+
import { Component, View, ViewEncapsulation, enableProdMode } from 'angular2/core';
22
import { CORE_DIRECTIVES, NgStyle, FORM_DIRECTIVES } from 'angular2/common';
33
import { bootstrap } from 'angular2/platform/browser';
44
import { NgGrid, NgGridItem } from "./NgGrid";

src/index.html

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
<title>Angular 2 Grid Demo</title>
55
<link rel="stylesheet" href="lib/bootstrap.min.css" />
66
<script src="lib/es6-shim.min.js"></script>
7+
<script src="lib/angular2-polyfills.min.js"></script>
78
<script src="lib/system.js"></script>
8-
<script src="lib/Reflect.js"></script>
9+
<script src="lib/Rx.min.js"></script>
910
<script src="lib/angular2.min.js"></script>
1011
</head>
1112
<body>
@@ -17,9 +18,6 @@
1718
packages: {
1819
'angular2': {
1920
defaultExtension: false
20-
},
21-
'rxjs': {
22-
defaultExtension: false
2321
}
2422
}
2523
});

0 commit comments

Comments
 (0)