mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
perf(item): improve performance of sliding item (#9005)
- Using new NativeRafDebouncer - Events are not zone wrapped unless strictly necessary
This commit is contained in:
committed by
Brandy Carney
parent
f38fe8d313
commit
759e3ea62d
@@ -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;
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user