Skip to content

Commit 2992b77

Browse files
committed
Fixes
1 parent 9be92f5 commit 2992b77

File tree

7 files changed

+74
-50
lines changed

7 files changed

+74
-50
lines changed

Diff for: dist/vue-virtual-scroller.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs-src/src/App.vue

+2-7
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export default {
109109
generateItems () {
110110
console.log('Generating ' + this.count + ' items...')
111111
let time = Date.now()
112-
const items = Object.freeze(getData(this.count, this.enableLetters))
112+
const items = getData(this.count, this.enableLetters)
113113
this._time = Date.now()
114114
this.generateTime = this._time - time
115115
console.log('Generated ' + items.length + ' in ' + this.generateTime + 'ms')
@@ -207,12 +207,7 @@ body {
207207
.letter {
208208
text-transform: uppercase;
209209
color: grey;
210-
font-weight: lighter;
211-
height: 200px;
212-
}
213-
214-
.letter .value {
215-
font-size: 120px;
210+
font-weight: bold;
216211
}
217212
218213
.index {

Diff for: docs-src/src/Letter.vue

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<tr class="letter">
2+
<tr class="letter" :class="{ big: big }" @click="toggle">
33
<td class="index">
44
{{item.index}}
55
</td>
@@ -12,5 +12,28 @@
1212
<script>
1313
export default {
1414
props: ['item'],
15+
16+
computed: {
17+
big () {
18+
return this.item.height === 200
19+
},
20+
},
21+
22+
methods: {
23+
toggle () {
24+
this.item.height = this.big ? 42 : 200
25+
},
26+
},
1527
}
1628
</script>
29+
30+
<style scoped>
31+
.letter.big {
32+
font-weight: normal;
33+
height: 200px;
34+
}
35+
36+
.letter.big .value {
37+
font-size: 120px;
38+
}
39+
</style>

Diff for: docs/build.js

+25-25
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: docs/build.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-virtual-scroller",
33
"description": "Smooth scrolling for any amount of data",
4-
"version": "0.7.3",
4+
"version": "0.7.5",
55
"author": {
66
"name": "Guillaume Chau",
77
"email": "[email protected]"

Diff for: src/components/VirtualScroller.vue

+20-14
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,30 @@ export default {
104104
},
105105
106106
heights () {
107-
const heights = {}
108-
const items = this.items
109-
const field = this.heightField
110-
let accumulator = 0
111-
for (let i = 0; i < items.length; i++) {
112-
accumulator += items[i][field]
113-
heights[i] = accumulator
107+
if (this.itemHeight === null) {
108+
const heights = {}
109+
const items = this.items
110+
const field = this.heightField
111+
let accumulator = 0
112+
for (let i = 0; i < items.length; i++) {
113+
accumulator += items[i][field]
114+
heights[i] = accumulator
115+
}
116+
return heights
114117
}
115-
return heights
116118
},
117119
},
118120
119121
watch: {
120-
items () {
121-
this.updateVisibleItems()
122+
items: {
123+
handler () {
124+
this.updateVisibleItems(true)
125+
},
126+
deep: true,
122127
},
123128
pageMode () {
124129
this.applyPageMode()
125-
this.updateVisibleItems()
130+
this.updateVisibleItems(true)
126131
},
127132
},
128133
@@ -160,7 +165,7 @@ export default {
160165
}
161166
},
162167
163-
updateVisibleItems () {
168+
updateVisibleItems (force = false) {
164169
const l = this.items.length
165170
const scroll = this.getScroll()
166171
const items = this.items
@@ -224,10 +229,11 @@ export default {
224229
containerHeight = l * itemHeight
225230
}
226231
227-
if (startIndex !== this._startIndex || endIndex !== this._endIndex) {
232+
if (force || startIndex !== this._startIndex || endIndex !== this._endIndex || l !== this._length) {
228233
this.keysEnabled = !(startIndex > this._endIndex || endIndex < this._startIndex)
229234
this._startIndex = startIndex
230235
this._endIndex = endIndex
236+
this._length = l
231237
this.visibleItems = items.slice(startIndex, endIndex)
232238
this.itemContainerStyle = {
233239
height: containerHeight + 'px',
@@ -275,8 +281,8 @@ export default {
275281
},
276282
277283
mounted () {
278-
this.updateVisibleItems()
279284
this.applyPageMode()
285+
this.updateVisibleItems()
280286
},
281287
282288
beforeDestroy () {

0 commit comments

Comments
 (0)