mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(scrollView): ensure scroll element exists for event listeners
Related #6104
This commit is contained in:
@ -132,18 +132,20 @@ export class ScrollView {
|
|||||||
this._cb = onScrollCallback;
|
this._cb = onScrollCallback;
|
||||||
this._pos = [];
|
this._pos = [];
|
||||||
|
|
||||||
this._el.addEventListener('touchstart', this._start.bind(this));
|
if (this._el) {
|
||||||
this._el.addEventListener('touchmove', this._move.bind(this));
|
this._el.addEventListener('touchstart', this._start.bind(this));
|
||||||
this._el.addEventListener('touchend', this._end.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');
|
this._el.parentElement.classList.add('js-scroll');
|
||||||
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
this._el.removeEventListener('touchstart', this._start.bind(this));
|
if (this._el) {
|
||||||
this._el.removeEventListener('touchmove', this._move.bind(this));
|
this._el.removeEventListener('touchstart', this._start.bind(this));
|
||||||
this._el.removeEventListener('touchend', this._end.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');
|
this._el.parentElement.classList.remove('js-scroll');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user