Skip to content

Commit fdc7a42

Browse files
committed
Support getSize and getSizes
1 parent 89a4ca1 commit fdc7a42

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,10 @@ Here are some usefull public methods you can call via [`ref`](https://vuejs.org/
283283

284284
* `scrollToOffset(offset)`: manual set scroll position to a designated offset.
285285

286+
* `getSize(id)`: get the designated item size by id (from data-key value).
287+
288+
* `getSizes()`: get the total number of stored (rendered) items.
289+
286290

287291
## Attentions
288292

src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ const VirtualList = Vue.component('virtual-list', {
7676
},
7777

7878
methods: {
79+
// get item size by id
80+
getSize (id) {
81+
return this.virtual.sizes.get(id)
82+
},
83+
84+
// get the total number of stored (rendered) items
85+
getSizes () {
86+
return this.virtual.sizes.size
87+
},
88+
7989
// set current scroll position to a expectant offset
8090
scrollToOffset (offset) {
8191
const { root } = this.$refs

0 commit comments

Comments
 (0)