mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
fix(content): unsubscribe from viewCtrl observables after content ins… (#10050)
* fix(content): unsubscribe from observables on destroy * fix(content): scroll is initialized before subscribing fixes #9593 fixes #10045 * fix(content): unset viewCtrl subscribers on destroy
This commit is contained in:

committed by
Manu Mtz.-Almeida

parent
fba159662e
commit
3a718de463
@ -167,6 +167,10 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
||||
_fixedEle: HTMLElement;
|
||||
/** @internal */
|
||||
_imgs: Img[] = [];
|
||||
/** @internal */
|
||||
_viewCtrlReadSub: any;
|
||||
/** @internal */
|
||||
_viewCtrlWriteSub: any;
|
||||
|
||||
private _imgReqBfr: number;
|
||||
private _imgRndBfr: number;
|
||||
@ -328,33 +332,28 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
||||
this._imgReqBfr = config.getNumber('imgRequestBuffer', 1400);
|
||||
this._imgRndBfr = config.getNumber('imgRenderBuffer', 400);
|
||||
this._imgVelMax = config.getNumber('imgVelocityMax', 3);
|
||||
this._scroll = new ScrollView(_plt, _dom);
|
||||
|
||||
if (viewCtrl) {
|
||||
// content has a view controller
|
||||
viewCtrl._setIONContent(this);
|
||||
viewCtrl._setIONContentRef(elementRef);
|
||||
|
||||
var readSub = viewCtrl.readReady.subscribe(() => {
|
||||
readSub.unsubscribe();
|
||||
this._viewCtrlReadSub = viewCtrl.readReady.subscribe(() => {
|
||||
this._viewCtrlReadSub.unsubscribe();
|
||||
this._readDimensions();
|
||||
});
|
||||
|
||||
var writeSub = viewCtrl.writeReady.subscribe(() => {
|
||||
writeSub.unsubscribe();
|
||||
this._viewCtrlWriteSub = viewCtrl.writeReady.subscribe(() => {
|
||||
this._viewCtrlWriteSub.unsubscribe();
|
||||
this._writeDimensions();
|
||||
});
|
||||
|
||||
} else {
|
||||
// content does not have a view controller
|
||||
_dom.read(() => {
|
||||
this._readDimensions();
|
||||
});
|
||||
_dom.write(() => {
|
||||
this._writeDimensions();
|
||||
});
|
||||
_dom.read(this._readDimensions.bind(this));
|
||||
_dom.write(this._writeDimensions.bind(this));
|
||||
}
|
||||
|
||||
this._scroll = new ScrollView(_plt, _dom);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -400,6 +399,9 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
||||
*/
|
||||
ngOnDestroy() {
|
||||
this._scLsn && this._scLsn();
|
||||
this._viewCtrlReadSub && this._viewCtrlReadSub.unsubscribe();
|
||||
this._viewCtrlWriteSub && this._viewCtrlWriteSub.unsubscribe();
|
||||
this._viewCtrlReadSub = this._viewCtrlWriteSub = null;
|
||||
this._scroll && this._scroll.destroy();
|
||||
this._scrollEle = this._fixedEle = this._footerEle = this._scLsn = this._scroll = null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user