Skip to content

Commit d106a4d

Browse files
committed
Support page mode.
1 parent 5a7f671 commit d106a4d

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ According to the demos above, here are lists of approximate statistics:
202202
| rtag | String | * | Default value is `div`, the virtual-list root element tag name, in all cases it's style is set to `display: block;` |
203203
| wtag | String | * | Default value is `div`, the virtual-list item wrapper element tag name, in all cases it's style is set to `display: block;` |
204204
| wclass | String | * | Default is no classname, the virtual-list item wrapper element class, if assign this prop, you better **not** to change it's [CSS box model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model). |
205+
| pagemode | Boolean | * | Let virtual-list scroll with page viewport. |
205206
| totop | Function | * | Called when virtual-list is scrolled to top, no param. |
206207
| tobottom | Function | * | Called when virtual-list is scrolled to bottom, no param. |
207208
| onscroll | Function | * | Called when virtual-list is scrolling, with param: [`(event, data)`](https://github.com/tangbc/vue-virtual-scroll-list/releases/tag/v1.1.7). |

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

src/index.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
if (this.pagemode) {
163163
window.addEventListener('scroll', this.debounce ? _debounce(this.onScroll.bind(this), this.debounce) : this.onScroll, false)
164164
}
165+
165166
if (this.start) {
166167
const start = this.getZone(this.start).start
167168
this.setScrollTop(this.variable ? this.getVarOffset(start) : start * this.size)
@@ -522,15 +523,21 @@
522523
const list = this.filter(h)
523524
const { paddingTop, paddingBottom } = this.delta
524525

526+
const renderList = h(this.wtag, {
527+
'style': {
528+
'display': 'block',
529+
'padding-top': paddingTop + 'px',
530+
'padding-bottom': paddingBottom + 'px'
531+
},
532+
'class': this.wclass,
533+
'attrs': {
534+
'role': 'group'
535+
}
536+
}, list)
537+
538+
// page mode just render list, no wraper.
525539
if (this.pagemode) {
526-
return h(this.wtag, {
527-
'style': {
528-
'display': 'block',
529-
'padding-top': paddingTop + 'px',
530-
'padding-bottom': paddingBottom + 'px'
531-
},
532-
'class': this.wclass
533-
}, list)
540+
return renderList
534541
}
535542

536543
return h(this.rtag, {
@@ -544,17 +551,7 @@
544551
'&scroll': dbc ? _debounce(this.onScroll.bind(this), dbc) : this.onScroll
545552
}
546553
}, [
547-
h(this.wtag, {
548-
'style': {
549-
'display': 'block',
550-
'padding-top': paddingTop + 'px',
551-
'padding-bottom': paddingBottom + 'px'
552-
},
553-
'class': this.wclass,
554-
'attrs': {
555-
'role': 'group'
556-
}
557-
}, list)
554+
renderList
558555
])
559556
}
560557
})

0 commit comments

Comments
 (0)