File tree Expand file tree Collapse file tree 4 files changed +26
-17
lines changed Expand file tree Collapse file tree 4 files changed +26
-17
lines changed Original file line number Diff line number Diff line change @@ -268,6 +268,12 @@ export class Pager extends PagerBase {
268
268
disposeViewHolderViews ( ) {
269
269
this . enumerateViewHolders ( ( v ) => {
270
270
const view = v . view ;
271
+ this . notify ( {
272
+ eventName : Pager . itemDisposingEvent ,
273
+ index : v . getAdapterPosition ( ) ,
274
+ android : v ,
275
+ view
276
+ } as ItemEventData ) ;
271
277
// if (view && view.isLoaded) {
272
278
// view.callUnloaded();
273
279
// }
Original file line number Diff line number Diff line change @@ -505,11 +505,10 @@ export class Pager extends PagerBase {
505
505
}
506
506
507
507
private clearRealizedCells ( ) {
508
- const that = new WeakRef < Pager > ( this ) ;
509
- this . mMap . forEach ( function ( value , key : PagerCell ) {
510
- that . get ( ) . _removeContainer ( key ) ;
511
- that . get ( ) . _clearCellViews ( key ) ;
512
- } , that ) ;
508
+ this . mMap . forEach ( ( value , key : PagerCell ) => {
509
+ this . _removeContainer ( key ) ;
510
+ this . _clearCellViews ( key ) ;
511
+ } ) ;
513
512
this . mMap . clear ( ) ;
514
513
}
515
514
private _clearCellViews ( cell : PagerCell ) {
@@ -560,18 +559,14 @@ export class Pager extends PagerBase {
560
559
}
561
560
562
561
public _removeContainer ( cell : PagerCell , index ?: number ) : void {
563
- let view = cell . view ;
562
+ const view = cell . view ;
564
563
565
- const args = {
564
+ this . notify ( {
566
565
eventName : Pager . itemDisposingEvent ,
567
- object : this ,
568
566
index,
569
- android : undefined ,
570
567
ios : cell ,
571
568
view
572
- } as ItemEventData ;
573
- this . notify ( args ) ;
574
- view = args . view ;
569
+ } as ItemEventData ) ;
575
570
if ( view && view . parent ) {
576
571
// This is to clear the StackLayout that is used to wrap ProxyViewContainer instances.
577
572
if ( ! ( view . parent instanceof Pager ) ) {
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ export default class PagerViewElement extends NativeViewElementNode<Pager> {
54
54
const nativeView = this . nativeView ;
55
55
nativeView . itemViewLoader = ( viewType : any ) : View => this . loadView ( viewType ) ;
56
56
this . nativeView . on ( Pager . itemLoadingEvent , this . updateListItem , this ) ;
57
+ this . nativeView . on ( Pager . itemDisposingEvent , this . disposeListItem , this ) ;
57
58
}
58
59
59
60
private loadView ( viewType : string ) : View {
@@ -118,6 +119,13 @@ export default class PagerViewElement extends NativeViewElementNode<Pager> {
118
119
}
119
120
}
120
121
}
122
+ private disposeListItem ( args : ItemEventData ) {
123
+ const _view = args . view ;
124
+ if ( _view . __SvelteComponent__ ) {
125
+ _view . __SvelteComponent__ . $destroy ( ) ;
126
+ _view . __SvelteComponent__ = null ;
127
+ }
128
+ }
121
129
private updateListItem ( args : ItemEventData & { bindingContext } ) {
122
130
const _view = args . view ;
123
131
const props = { item : args . bindingContext , index : args . index } ;
Original file line number Diff line number Diff line change @@ -93,11 +93,11 @@ export default {
93
93
} ,
94
94
onItemDisposing ( args ) {
95
95
// TODO: handle disposing template
96
- // const oldVnode = args.view && args.view[ VUE_VIEW ];
97
- // console.log("disposing", !! oldVnode, VUE_VIEW);
98
- // if ( oldVnode) {
99
- // Vue.prototype .__patch__(oldVnode, null);
100
- // }
96
+ const oldVnode = args . view && args . view [ VUE_VIEW ] ;
97
+ if ( oldVnode ) {
98
+ // properly dispose the oldVnode (this will unmount the tree)
99
+ this . __patch__ ( oldVnode , null ) ;
100
+ }
101
101
} ,
102
102
onSelectedIndexChange ( { value } ) {
103
103
this . $emit ( 'selectedIndexChange' , {
You can’t perform that action at this time.
0 commit comments