Skip to content

Commit

Permalink
fix(gestures): drag events are debounced
Browse files Browse the repository at this point in the history
- Performance regressions in menu, sliding item, toggle, go back swipe and scroll up to refresh.
- Buggy sliding item
  • Loading branch information
manucorporat committed Jan 20, 2017
1 parent ee2268f commit 23a70e1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
42 changes: 19 additions & 23 deletions src/components/item/item-sliding.ts
Expand Up @@ -315,12 +315,7 @@ export class ItemSliding {
openAmount = optsWidth + (openAmount - optsWidth) * ELASTIC_FACTOR;
}

// this.debouncer.write(() => {

// });
this._dom.write(() => {
this._setOpenAmount(openAmount, false);
});
this._setOpenAmount(openAmount, false);

return openAmount;
}
Expand Down Expand Up @@ -362,29 +357,30 @@ export class ItemSliding {
* @private
*/
private calculateOptsWidth() {
this._plt.raf(() => {
if (!this._optsDirty) {
return;
}
this._optsWidthRightSide = 0;
if (this._rightOptions) {
this._optsWidthRightSide = this._rightOptions.width();
assert(this._optsWidthRightSide > 0, '_optsWidthRightSide should not be zero');
}
if (!this._optsDirty) {
return;
}
this._optsWidthRightSide = 0;
if (this._rightOptions) {
this._optsWidthRightSide = this._rightOptions.width();
assert(this._optsWidthRightSide > 0, '_optsWidthRightSide should not be zero');
}

this._optsWidthLeftSide = 0;
if (this._leftOptions) {
this._optsWidthLeftSide = this._leftOptions.width();
assert(this._optsWidthLeftSide > 0, '_optsWidthLeftSide should not be zero');
}
this._optsDirty = false;
});
this._optsWidthLeftSide = 0;
if (this._leftOptions) {
this._optsWidthLeftSide = this._leftOptions.width();
assert(this._optsWidthLeftSide > 0, '_optsWidthLeftSide should not be zero');
}
this._optsDirty = false;
}

private _setOpenAmount(openAmount: number, isFinal: boolean) {
const platform = this._plt;

platform.cancelTimeout(this._tmr);
if (this._tmr) {
platform.cancelTimeout(this._tmr);
this._tmr = null;
}
this._openAmount = openAmount;

if (isFinal) {
Expand Down
4 changes: 3 additions & 1 deletion src/gestures/drag-gesture.ts
Expand Up @@ -110,7 +110,9 @@ export class PanGesture {
pointerMove(ev: any) {
assert(this.started === true, 'started must be true');
if (this.captured) {
this.onDragMove(ev);
this.debouncer.write(() => {
this.onDragMove(ev);
});
return;
}

Expand Down

0 comments on commit 23a70e1

Please sign in to comment.