@@ -167,6 +167,10 @@ export class Content extends Ion implements OnDestroy, OnInit {
167
167
_fixedEle : HTMLElement ;
168
168
/** @internal */
169
169
_imgs : Img [ ] = [ ] ;
170
+ /** @internal */
171
+ _viewCtrlReadSub : any ;
172
+ /** @internal */
173
+ _viewCtrlWriteSub : any ;
170
174
171
175
private _imgReqBfr : number ;
172
176
private _imgRndBfr : number ;
@@ -328,33 +332,28 @@ export class Content extends Ion implements OnDestroy, OnInit {
328
332
this . _imgReqBfr = config . getNumber ( 'imgRequestBuffer' , 1400 ) ;
329
333
this . _imgRndBfr = config . getNumber ( 'imgRenderBuffer' , 400 ) ;
330
334
this . _imgVelMax = config . getNumber ( 'imgVelocityMax' , 3 ) ;
335
+ this . _scroll = new ScrollView ( _plt , _dom ) ;
331
336
332
337
if ( viewCtrl ) {
333
338
// content has a view controller
334
339
viewCtrl . _setIONContent ( this ) ;
335
340
viewCtrl . _setIONContentRef ( elementRef ) ;
336
341
337
- var readSub = viewCtrl . readReady . subscribe ( ( ) => {
338
- readSub . unsubscribe ( ) ;
342
+ this . _viewCtrlReadSub = viewCtrl . readReady . subscribe ( ( ) => {
343
+ this . _viewCtrlReadSub . unsubscribe ( ) ;
339
344
this . _readDimensions ( ) ;
340
345
} ) ;
341
346
342
- var writeSub = viewCtrl . writeReady . subscribe ( ( ) => {
343
- writeSub . unsubscribe ( ) ;
347
+ this . _viewCtrlWriteSub = viewCtrl . writeReady . subscribe ( ( ) => {
348
+ this . _viewCtrlWriteSub . unsubscribe ( ) ;
344
349
this . _writeDimensions ( ) ;
345
350
} ) ;
346
351
347
352
} else {
348
353
// content does not have a view controller
349
- _dom . read ( ( ) => {
350
- this . _readDimensions ( ) ;
351
- } ) ;
352
- _dom . write ( ( ) => {
353
- this . _writeDimensions ( ) ;
354
- } ) ;
354
+ _dom . read ( this . _readDimensions . bind ( this ) ) ;
355
+ _dom . write ( this . _writeDimensions . bind ( this ) ) ;
355
356
}
356
-
357
- this . _scroll = new ScrollView ( _plt , _dom ) ;
358
357
}
359
358
360
359
/**
@@ -400,6 +399,9 @@ export class Content extends Ion implements OnDestroy, OnInit {
400
399
*/
401
400
ngOnDestroy ( ) {
402
401
this . _scLsn && this . _scLsn ( ) ;
402
+ this . _viewCtrlReadSub && this . _viewCtrlReadSub . unsubscribe ( ) ;
403
+ this . _viewCtrlWriteSub && this . _viewCtrlWriteSub . unsubscribe ( ) ;
404
+ this . _viewCtrlReadSub = this . _viewCtrlWriteSub = null ;
403
405
this . _scroll && this . _scroll . destroy ( ) ;
404
406
this . _scrollEle = this . _fixedEle = this . _footerEle = this . _scLsn = this . _scroll = null ;
405
407
}
0 commit comments