@@ -82,10 +82,18 @@ export default {
82
82
for (let i = 0 ; i < items .length ; i++ ) {
83
83
const item = items[i]
84
84
const id = item[keyField]
85
+ let height = heights[id]
86
+ if (typeof height === ' undefined' && ! this .$_undefinedMap [id]) {
87
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
88
+ this .$_undefinedHeights ++
89
+ // eslint-disable-next-line vue/no-side-effects-in-computed-properties
90
+ this .$_undefinedMap [id] = true
91
+ height = 0
92
+ }
85
93
result .push ({
86
94
item,
87
95
id,
88
- height: heights[id] || 0 ,
96
+ height,
89
97
})
90
98
}
91
99
return result
@@ -110,6 +118,8 @@ export default {
110
118
111
119
created () {
112
120
this .$_updates = []
121
+ this .$_undefinedHeights = 0
122
+ this .$_undefinedMap = {}
113
123
},
114
124
115
125
mounted () {
@@ -153,6 +163,30 @@ export default {
153
163
const scroller = this .$refs .scroller
154
164
if (scroller) scroller .scrollToItem (index)
155
165
},
166
+
167
+ getItemSize (item ) {
168
+ const id = item[this .keyField ]
169
+ return this .vscrollData .heights [id] || 0
170
+ },
171
+
172
+ scrollToBottom () {
173
+ if (this .$_scrollingToBottom ) return
174
+ this .$_scrollingToBottom = true
175
+ const el = this .$el
176
+ // Item is inserted to the DOM
177
+ this .$nextTick (() => {
178
+ // Item sizes are computed
179
+ const cb = () => {
180
+ el .scrollTop = el .scrollHeight
181
+ if (this .$_undefinedHeights === 0 ) {
182
+ this .$_scrollingToBottom = false
183
+ } else {
184
+ requestAnimationFrame (cb)
185
+ }
186
+ }
187
+ requestAnimationFrame (cb)
188
+ })
189
+ },
156
190
},
157
191
}
158
192
</script >
0 commit comments