Skip to content

Commit

Permalink
chore(plugin/overscroll): rename vars
Browse files Browse the repository at this point in the history
  • Loading branch information
idiotWu committed Oct 19, 2017
1 parent eae0b86 commit 7514d64
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/plugins/overscroll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class OverscrollPlugin extends ScrollbarPlugin {
private _glow = new Glow(this.scrollbar);
private _bounce = new Bounce(this.scrollbar);

private _scrollBack = {
private _wheelScrollBack = {
x: false,
y: false,
};
Expand All @@ -51,7 +51,7 @@ export default class OverscrollPlugin extends ScrollbarPlugin {
return this._lockWheel.x || this._lockWheel.y;
}

private _paused = false;
private _touching = false;

private _lastEventType: string;

Expand Down Expand Up @@ -189,13 +189,13 @@ export default class OverscrollPlugin extends ScrollbarPlugin {
switch (fromEvent.type) {
case 'touchstart':
case 'touchmove':
this._paused = true;
this._touching = true;
this._glow.recordTouch(fromEvent as TouchEvent);
break;

case 'touchcancel':
case 'touchend':
this._paused = false;
this._touching = false;
break;
}

Expand Down Expand Up @@ -261,7 +261,7 @@ export default class OverscrollPlugin extends ScrollbarPlugin {
// opposite direction
friction = 0;
} else {
friction = this._scrollBack[direction] ?
friction = this._wheelScrollBack[direction] ?
1 : Math.abs(currentAmp / options.maxOverscroll);
}

Expand Down Expand Up @@ -319,16 +319,16 @@ export default class OverscrollPlugin extends ScrollbarPlugin {
const amp = _amplitude[direction];
const pos = _position[direction];

const nextAmp = this._paused ? amp : (amp * t | 0);
const nextAmp = this._touching ? amp : (amp * t | 0);
const distance = nextAmp - pos;
const nextPos = pos + distance - (distance * t | 0);

if (Math.abs(nextPos) < Math.abs(pos)) {
this._scrollBack[direction] = true;
if (!this._touching && Math.abs(nextPos) < Math.abs(pos)) {
this._wheelScrollBack[direction] = true;
}

if (this._scrollBack[direction] && Math.abs(nextPos) <= 1) {
this._scrollBack[direction] = false;
if (this._wheelScrollBack[direction] && Math.abs(nextPos) <= 1) {
this._wheelScrollBack[direction] = false;
this._lockWheel[direction] = true;
}

Expand Down

0 comments on commit 7514d64

Please sign in to comment.