Skip to content

Commit 759e3ea

Browse files
manucorporatbrandyscarney
authored andcommitted
perf(item): improve performance of sliding item (#9005)
- Using new NativeRafDebouncer - Events are not zone wrapped unless strictly necessary
1 parent f38fe8d commit 759e3ea

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/components/item/item-sliding-gesture.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { List } from '../list/list';
44
import { GesturePriority } from '../../gestures/gesture-controller';
55
import { PanGesture } from '../../gestures/drag-gesture';
66
import { pointerCoord } from '../../util/dom';
7+
import { NativeRafDebouncer } from '../../util/debouncer';
78

89
const DRAG_THRESHOLD = 10;
910
const MAX_ATTACK_ANGLE = 20;
@@ -19,6 +20,8 @@ export class ItemSlidingGesture extends PanGesture {
1920
super(list.getNativeElement(), {
2021
maxAngle: MAX_ATTACK_ANGLE,
2122
threshold: DRAG_THRESHOLD,
23+
zone: false,
24+
debouncer: new NativeRafDebouncer(),
2225
gesture: list._gestureCtrl.create('item-sliding', {
2326
priority: GesturePriority.SlidingItem,
2427
})

src/components/item/item-sliding.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,10 @@ export class ItemSliding {
402402
}
403403

404404
this.item.setElementStyle(CSS.transform, `translate3d(${-openAmount}px,0,0)`);
405-
this._zone.run(() => this.ionDrag.emit(this));
405+
let ionDrag = this.ionDrag;
406+
if (ionDrag.observers.length > 0) {
407+
this._zone.run(ionDrag.emit.bind(ionDrag, this));
408+
}
406409
}
407410

408411
private _setState(state: SlidingState) {

0 commit comments

Comments
 (0)