Skip to content

Commit efc9bd1

Browse files
committed
Fixed end index overflow.
1 parent 20de341 commit efc9bd1

File tree

6 files changed

+19
-11
lines changed

6 files changed

+19
-11
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
* Support fixed height and variable height.
2424

25-
* Support set the initial scroll index or offset.
25+
* Support set the scroll index or offset to any.
2626

2727
* Event scroll, reach top and bottom can be detected.
2828

@@ -53,7 +53,7 @@ npm install vue-virtual-scroll-list --save
5353
<template>
5454
<div>
5555
<virtual-list :size="40" :remain="8">
56-
<item v-for="(item, index) of items" :key="item.id" />
56+
<item v-for="item of items" :key="item.id" />
5757
</virtual-list>
5858
</div>
5959
</template>
@@ -65,7 +65,7 @@ npm install vue-virtual-scroll-list --save
6565
export default {
6666
data () {
6767
return {
68-
items: [...]
68+
items: [ {id: 1} ... ]
6969
}
7070
},
7171
components: { item, 'virtual-list': virtualList }
@@ -129,9 +129,9 @@ new Vue({
129129

130130
### About variable height
131131

132-
In variable height mode, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<Item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cache, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
132+
In variable height mode, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cache, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
133133

134-
If you are using `variable` assign by `Boolean`, **do not** set inline style height inside `<item/>` component, you must set inline style height on `<item/>` component outside directly, such as:
134+
If you are using `variable` assign by `Boolean`, **do not** set inline style height inside `<item/>` component, you **must** set inline style height on `<item/>` component outside directly, such as:
135135
```vue
136136
<template>
137137
<div>

examples/build/finite.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/build/infinite.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/build/variable.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@
9494

9595
if (delta.total > delta.keeps) {
9696
this.updateZone(offset)
97+
} else {
98+
delta.end = delta.total - 1
9799
}
98100

99101
var offsetAll = delta.offsetAll
@@ -256,7 +258,7 @@
256258
var lastStart = delta.total - delta.keeps
257259
var isLast = (index <= delta.total && index >= lastStart) || (index > delta.total)
258260
if (isLast) {
259-
end = delta.total
261+
end = delta.total - 1
260262
start = Math.max(0, lastStart)
261263
} else {
262264
start = index

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vue-virtual-scroll-list",
3-
"version": "1.2.0",
4-
"description": "A vue (2.x) component that support big data and infinite loading by using virtual scroll list.",
3+
"version": "1.2.1",
4+
"description": "A vue (2.x) component that support big data list with high scroll performance.",
55
"main": "index.js",
66
"files": [
77
"index.js"

0 commit comments

Comments
 (0)