perf(itemSliding): improve performance

This commit is contained in:
Adam Bradley
2015-11-18 23:32:25 -06:00
parent 564b674ba7
commit b2d9e1d8a3
5 changed files with 55 additions and 37 deletions

View File

@@ -33,6 +33,7 @@ export class List extends Ion {
constructor(elementRef: ElementRef, config: Config, private zone: NgZone) {
super(elementRef, config);
this.ele = elementRef.nativeElement;
this._enableSliding = false;
}
/**
@@ -76,18 +77,22 @@ export class List extends Ion {
}
enableSlidingItems(shouldEnable) {
this._enableSliding = shouldEnable;
if (this._init) {
if (shouldEnable) {
this.zone.runOutsideAngular(() => {
setTimeout(() => {
this.slidingGesture = new ItemSlidingGesture(this, this.ele);
});
});
} else {
this.slidingGesture && this.slidingGesture.unlisten();
if (this._enableSliding !== shouldEnable) {
this._enableSliding = shouldEnable;
if (shouldEnable) {
console.debug('enableSlidingItems');
this.zone.runOutsideAngular(() => {
setTimeout(() => {
this.slidingGesture = new ItemSlidingGesture(this, this.ele);
});
});
} else {
this.slidingGesture && this.slidingGesture.unlisten();
}
}
}
}