Skip to content

Commit 4c2e74f

Browse files
committed
Build v2.1.7
1 parent 70b1980 commit 4c2e74f

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

dist/index.js

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* vue-virtual-scroll-list v2.1.6
2+
* vue-virtual-scroll-list v2.1.7
33
* open source under the MIT license
44
* https://github.com/tangbc/vue-virtual-scroll-list#readme
55
*/
@@ -113,7 +113,7 @@
113113
}, {
114114
key: "getOffset",
115115
value: function getOffset(start) {
116-
return start < 1 ? 0 : this.getIndexOffset(start);
116+
return (start < 1 ? 0 : this.getIndexOffset(start)) + this.param.slotHeaderSize;
117117
}
118118
}, {
119119
key: "updateParam",
@@ -407,6 +407,10 @@
407407
type: Number,
408408
"default": 0
409409
},
410+
pageMode: {
411+
type: Boolean,
412+
"default": false
413+
},
410414
rootTag: {
411415
type: String,
412416
"default": 'div'
@@ -626,6 +630,19 @@
626630
this.scrollToIndex(this.start);
627631
} else if (this.offset) {
628632
this.scrollToOffset(this.offset);
633+
} // in page mode we bind scroll event to document
634+
635+
636+
if (this.pageMode) {
637+
document.addEventListener('scroll', this.onScroll, {
638+
passive: false
639+
}); // taking root offsetTop or offsetLeft as slot header size
640+
641+
var root = this.$refs.root;
642+
643+
if (root) {
644+
this.virtual.updateParam('slotHeaderSize', root[this.isHorizontal ? 'offsetLeft' : 'offsetTop']);
645+
}
629646
}
630647
},
631648
beforeDestroy: function beforeDestroy() {
@@ -642,25 +659,45 @@
642659
},
643660
// return current scroll offset
644661
getOffset: function getOffset() {
645-
var root = this.$refs.root;
646-
return root ? Math.ceil(root[this.directionKey]) : 0;
662+
if (this.pageMode) {
663+
return document.documentElement[this.directionKey];
664+
} else {
665+
var root = this.$refs.root;
666+
return root ? Math.ceil(root[this.directionKey]) : 0;
667+
}
647668
},
648669
// return client viewport size
649670
getClientSize: function getClientSize() {
650-
var root = this.$refs.root;
651-
return root ? root[this.isHorizontal ? 'clientWidth' : 'clientHeight'] : 0;
671+
var key = this.isHorizontal ? 'clientWidth' : 'clientHeight';
672+
673+
if (this.pageMode) {
674+
return document.documentElement[key];
675+
} else {
676+
var root = this.$refs.root;
677+
return root ? root[key] : 0;
678+
}
652679
},
653680
// return all scroll size
654681
getScrollSize: function getScrollSize() {
655-
var root = this.$refs.root;
656-
return root ? root[this.isHorizontal ? 'scrollWidth' : 'scrollHeight'] : 0;
682+
var key = this.isHorizontal ? 'scrollWidth' : 'scrollHeight';
683+
684+
if (this.pageMode) {
685+
return document.documentElement[key];
686+
} else {
687+
var root = this.$refs.root;
688+
return root ? root[key] : 0;
689+
}
657690
},
658691
// set current scroll position to a expectant offset
659692
scrollToOffset: function scrollToOffset(offset) {
660-
var root = this.$refs.root;
693+
if (this.pageMode) {
694+
document.documentElement[this.directionKey] = offset;
695+
} else {
696+
var root = this.$refs.root;
661697

662-
if (root) {
663-
root[this.directionKey] = offset || 0;
698+
if (root) {
699+
root[this.directionKey] = offset;
700+
}
664701
}
665702
},
666703
// set current scroll position to a expectant index
@@ -819,6 +856,7 @@
819856
padFront = _this$range2.padFront,
820857
padBehind = _this$range2.padBehind;
821858
var isHorizontal = this.isHorizontal,
859+
pageMode = this.pageMode,
822860
rootTag = this.rootTag,
823861
wrapTag = this.wrapTag,
824862
wrapClass = this.wrapClass,
@@ -836,7 +874,7 @@
836874
return h(rootTag, {
837875
ref: 'root',
838876
on: {
839-
'&scroll': this.onScroll
877+
'&scroll': !pageMode && this.onScroll
840878
}
841879
}, [// header slot
842880
header ? h(Slot, {

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.1.6",
3+
"version": "2.1.7",
44
"description": "A vue component support big amount data list with high scroll performance.",
55
"main": "dist/index.js",
66
"files": [

0 commit comments

Comments
 (0)