mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-21 04:53:58 +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;
|
_fixedEle: HTMLElement;
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_imgs: Img[] = [];
|
_imgs: Img[] = [];
|
||||||
|
/** @internal */
|
||||||
|
_viewCtrlReadSub: any;
|
||||||
|
/** @internal */
|
||||||
|
_viewCtrlWriteSub: any;
|
||||||
|
|
||||||
private _imgReqBfr: number;
|
private _imgReqBfr: number;
|
||||||
private _imgRndBfr: number;
|
private _imgRndBfr: number;
|
||||||
@ -328,33 +332,28 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
|||||||
this._imgReqBfr = config.getNumber('imgRequestBuffer', 1400);
|
this._imgReqBfr = config.getNumber('imgRequestBuffer', 1400);
|
||||||
this._imgRndBfr = config.getNumber('imgRenderBuffer', 400);
|
this._imgRndBfr = config.getNumber('imgRenderBuffer', 400);
|
||||||
this._imgVelMax = config.getNumber('imgVelocityMax', 3);
|
this._imgVelMax = config.getNumber('imgVelocityMax', 3);
|
||||||
|
this._scroll = new ScrollView(_plt, _dom);
|
||||||
|
|
||||||
if (viewCtrl) {
|
if (viewCtrl) {
|
||||||
// content has a view controller
|
// content has a view controller
|
||||||
viewCtrl._setIONContent(this);
|
viewCtrl._setIONContent(this);
|
||||||
viewCtrl._setIONContentRef(elementRef);
|
viewCtrl._setIONContentRef(elementRef);
|
||||||
|
|
||||||
var readSub = viewCtrl.readReady.subscribe(() => {
|
this._viewCtrlReadSub = viewCtrl.readReady.subscribe(() => {
|
||||||
readSub.unsubscribe();
|
this._viewCtrlReadSub.unsubscribe();
|
||||||
this._readDimensions();
|
this._readDimensions();
|
||||||
});
|
});
|
||||||
|
|
||||||
var writeSub = viewCtrl.writeReady.subscribe(() => {
|
this._viewCtrlWriteSub = viewCtrl.writeReady.subscribe(() => {
|
||||||
writeSub.unsubscribe();
|
this._viewCtrlWriteSub.unsubscribe();
|
||||||
this._writeDimensions();
|
this._writeDimensions();
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// content does not have a view controller
|
// content does not have a view controller
|
||||||
_dom.read(() => {
|
_dom.read(this._readDimensions.bind(this));
|
||||||
this._readDimensions();
|
_dom.write(this._writeDimensions.bind(this));
|
||||||
});
|
|
||||||
_dom.write(() => {
|
|
||||||
this._writeDimensions();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._scroll = new ScrollView(_plt, _dom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,6 +399,9 @@ export class Content extends Ion implements OnDestroy, OnInit {
|
|||||||
*/
|
*/
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
this._scLsn && this._scLsn();
|
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._scroll && this._scroll.destroy();
|
||||||
this._scrollEle = this._fixedEle = this._footerEle = this._scLsn = this._scroll = null;
|
this._scrollEle = this._fixedEle = this._footerEle = this._scLsn = this._scroll = null;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user