Skip to content

Commit

Permalink
perf(item): improve performance of sliding item (#9005)
Browse files Browse the repository at this point in the history
- Using new NativeRafDebouncer
- Events are not zone wrapped unless strictly necessary
  • Loading branch information
manucorporat authored and brandyscarney committed Nov 4, 2016
1 parent f38fe8d commit 759e3ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/item/item-sliding-gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { List } from '../list/list';
import { GesturePriority } from '../../gestures/gesture-controller';
import { PanGesture } from '../../gestures/drag-gesture';
import { pointerCoord } from '../../util/dom';
import { NativeRafDebouncer } from '../../util/debouncer';

const DRAG_THRESHOLD = 10;
const MAX_ATTACK_ANGLE = 20;
Expand All @@ -19,6 +20,8 @@ export class ItemSlidingGesture extends PanGesture {
super(list.getNativeElement(), {
maxAngle: MAX_ATTACK_ANGLE,
threshold: DRAG_THRESHOLD,
zone: false,
debouncer: new NativeRafDebouncer(),
gesture: list._gestureCtrl.create('item-sliding', {
priority: GesturePriority.SlidingItem,
})
Expand Down
5 changes: 4 additions & 1 deletion src/components/item/item-sliding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,10 @@ export class ItemSliding {
}

this.item.setElementStyle(CSS.transform, `translate3d(${-openAmount}px,0,0)`);
this._zone.run(() => this.ionDrag.emit(this));
let ionDrag = this.ionDrag;
if (ionDrag.observers.length > 0) {
this._zone.run(ionDrag.emit.bind(ionDrag, this));
}
}

private _setState(state: SlidingState) {
Expand Down

0 comments on commit 759e3ea

Please sign in to comment.