Skip to content

Commit

Permalink
fix(virtual-repeat): correctly remove EventListener
Browse files Browse the repository at this point in the history
  • Loading branch information
martingust committed Feb 17, 2016
1 parent d698d6f commit fd39c21
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/virtual-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class VirtualRepeat {
}

detached() {
this.scrollContainer.removeEventListener('scroll');
this.scrollContainer.removeEventListener('scroll', this.scrollListener);
this._first = 0;
this._previousFirst = 0;
this._viewsLength = 0;
Expand All @@ -102,6 +102,7 @@ export class VirtualRepeat {
this._scrollingUp = false;
this._switchedDirection = false;
this._isAttached = false;
this._ticking = false;
this.viewStrategy.removeBufferElements(this.scrollList, this.topBuffer, this.bottomBuffer);
this.isLastIndex = false;
this.scrollList = null;
Expand All @@ -112,7 +113,7 @@ export class VirtualRepeat {
this.scrollHandler.dispose();
}
this._unsubscribeCollection();

}

itemsChanged() {
Expand Down Expand Up @@ -164,8 +165,8 @@ export class VirtualRepeat {
}
}

_onScroll() {
if(!this._ticking) {
_onScroll() {
if(!this._ticking) {
requestAnimationFrame(() => this._handleScroll());
this._ticking = true;
}
Expand All @@ -181,7 +182,7 @@ export class VirtualRepeat {
this._checkScrolling();
// TODO if and else paths do almost same thing, refactor?
// move views down?
if(this._isScrolling && this._scrollingDown && (this._hasScrolledDownTheBuffer() || (this._switchedDirection && this._hasScrolledDownTheBufferFromTop()))) {
if(this._scrollingDown && (this._hasScrolledDownTheBuffer() || (this._switchedDirection && this._hasScrolledDownTheBufferFromTop()))) {
let viewsToMove = this._first - this._lastRebind;
if(this._switchedDirection) {
viewsToMove = this.isAtTop ? this._first : this._bufferSize - (this._lastRebind - this._first);
Expand All @@ -198,7 +199,7 @@ export class VirtualRepeat {
this._adjustBufferHeights();
}
// move view up?
} else if (this._isScrolling && this._scrollingUp && (this._hasScrolledUpTheBuffer() || (this._switchedDirection && this._hasScrolledUpTheBufferFromBottom()))) {
} else if (this._scrollingUp && (this._hasScrolledUpTheBuffer() || (this._switchedDirection && this._hasScrolledUpTheBufferFromBottom()))) {
let viewsToMove = this._lastRebind - this._first;
if(this._switchedDirection) {
if(this.isLastIndex) {
Expand Down

0 comments on commit fd39c21

Please sign in to comment.