Skip to content

Commit 78654cc

Browse files
committed
Fixed keep-alive component loss offset #161
1 parent cb8e20b commit 78654cc

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
<a href="http://packagequality.com/#?package=vue-virtual-scroll-list">
1818
<img alt="Package quality" src="https://npm.packagequality.com/shield/vue-virtual-scroll-list.svg">
1919
</a>
20-
<a href="https://opensource.org/licenses/MIT">
21-
<img alt="License" src="https://img.shields.io/npm/l/vue-virtual-scroll-list.svg">
22-
</a>
2320
</p>
2421

2522
## Table of contents

dist/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-virtual-scroll-list v2.0.6
2+
* vue-virtual-scroll-list v2.0.7
33
* open source under the MIT license
44
* https://github.com/tangbc/vue-virtual-scroll-list#readme
55
*/
@@ -594,8 +594,9 @@
594594
this.$on(EVENT_TYPE.SLOT, this.onSlotResized);
595595
}
596596
},
597-
beforeDestroy: function beforeDestroy() {
598-
this.virtual.destroy();
597+
// set back offset when use keep-alive
598+
activated: function activated() {
599+
this.scrollToOffset(this.virtual.offset);
599600
},
600601
mounted: function mounted() {
601602
// set position
@@ -605,6 +606,9 @@
605606
this.scrollToOffset(this.offset);
606607
}
607608
},
609+
beforeDestroy: function beforeDestroy() {
610+
this.virtual.destroy();
611+
},
608612
methods: {
609613
// set current scroll position to a expectant offset
610614
scrollToOffset: function scrollToOffset(offset) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-virtual-scroll-list",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "A vue component support big amount data list with high scroll performance.",
55
"main": "dist/index.js",
66
"files": [

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ const VirtualList = Vue.component(NAME, {
5151
}
5252
},
5353

54-
beforeDestroy () {
55-
this.virtual.destroy()
54+
// set back offset when use keep-alive
55+
activated () {
56+
this.scrollToOffset(this.virtual.offset)
5657
},
5758

5859
mounted () {
@@ -64,6 +65,10 @@ const VirtualList = Vue.component(NAME, {
6465
}
6566
},
6667

68+
beforeDestroy () {
69+
this.virtual.destroy()
70+
},
71+
6772
methods: {
6873
// set current scroll position to a expectant offset
6974
scrollToOffset (offset) {

0 commit comments

Comments
 (0)