@@ -74,11 +74,21 @@ export default {
74
74
watch: {
75
75
watchData: ' updateWatchData' ,
76
76
77
- id () {
77
+ id (value , oldValue ) {
78
78
this .$el .$_vs_id = this .id
79
79
if (! this .size ) {
80
80
this .onDataUpdate ()
81
81
}
82
+
83
+ if (this .$_sizeObserved ) {
84
+ // In case the old item had the same size, it won't trigger the ResizeObserver
85
+ // since we are reusing the same DOM node
86
+ const oldSize = this .vscrollData .sizes [oldValue]
87
+ const size = this .vscrollData .sizes [value]
88
+ if (oldSize != null && oldSize !== size) {
89
+ this ._applySize (oldSize)
90
+ }
91
+ }
82
92
},
83
93
84
94
finalActive (value ) {
@@ -124,10 +134,8 @@ export default {
124
134
},
125
135
126
136
mounted () {
127
- if (this .vscrollData .active ) {
128
- if (! this .vscrollResizeObserver ) {
129
- this .updateSize ()
130
- }
137
+ if (this .finalActive ) {
138
+ this .updateSize ()
131
139
this .observeSize ()
132
140
}
133
141
},
@@ -193,26 +201,34 @@ export default {
193
201
applySize (width , height ) {
194
202
const size = ~~ (this .vscrollParent .direction === ' vertical' ? height : width)
195
203
if (size && this .size !== size) {
196
- if (this .vscrollParent .$_undefinedMap [this .id ]) {
197
- this .vscrollParent .$_undefinedSizes --
198
- this .vscrollParent .$_undefinedMap [this .id ] = undefined
199
- }
200
- this .vscrollData .sizes [this .id ] = size
201
- if (this .emitResize ) this .$emit (' resize' , this .id )
204
+ this ._applySize (size)
205
+ }
206
+ },
207
+
208
+ _applySize (size ) {
209
+ if (this .vscrollParent .$_undefinedMap [this .id ]) {
210
+ this .vscrollParent .$_undefinedSizes --
211
+ this .vscrollParent .$_undefinedMap [this .id ] = undefined
202
212
}
213
+ this .vscrollData .sizes [this .id ] = size
214
+ if (this .emitResize ) this .$emit (' resize' , this .id )
203
215
},
204
216
205
217
observeSize () {
206
218
if (! this .vscrollResizeObserver ) return
219
+ if (this .$_sizeObserved ) return
207
220
this .vscrollResizeObserver .observe (this .$el )
208
221
this .$el .$_vs_id = this .id
209
222
this .$el .$_vs_onResize = this .onResize
223
+ this .$_sizeObserved = true
210
224
},
211
225
212
226
unobserveSize () {
213
227
if (! this .vscrollResizeObserver ) return
228
+ if (! this .$_sizeObserved ) return
214
229
this .vscrollResizeObserver .unobserve (this .$el )
215
230
this .$el .$_vs_onResize = undefined
231
+ this .$_sizeObserved = false
216
232
},
217
233
218
234
onResize (id , width , height ) {
0 commit comments