Skip to content

Commit

Permalink
fix(scrollView): ensure scroll element exists for event listeners
Browse files Browse the repository at this point in the history
Related #6104
  • Loading branch information
adamdbradley committed Jun 9, 2016
1 parent f049521 commit 1188730
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/util/scroll-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,20 @@ export class ScrollView {
this._cb = onScrollCallback;
this._pos = [];

this._el.addEventListener('touchstart', this._start.bind(this));
this._el.addEventListener('touchmove', this._move.bind(this));
this._el.addEventListener('touchend', this._end.bind(this));

this._el.parentElement.classList.add('js-scroll');
if (this._el) {
this._el.addEventListener('touchstart', this._start.bind(this));
this._el.addEventListener('touchmove', this._move.bind(this));
this._el.addEventListener('touchend', this._end.bind(this));
this._el.parentElement.classList.add('js-scroll');
}

return () => {
this._el.removeEventListener('touchstart', this._start.bind(this));
this._el.removeEventListener('touchmove', this._move.bind(this));
this._el.removeEventListener('touchend', this._end.bind(this));

this._el.parentElement.classList.remove('js-scroll');
if (this._el) {
this._el.removeEventListener('touchstart', this._start.bind(this));
this._el.removeEventListener('touchmove', this._move.bind(this));
this._el.removeEventListener('touchend', this._end.bind(this));
this._el.parentElement.classList.remove('js-scroll');
}
};
}

Expand Down

0 comments on commit 1188730

Please sign in to comment.