Skip to content

Commit e2fa344

Browse files
committed
Support designate klass.
1 parent a8163fc commit e2fa344

File tree

8 files changed

+40
-42
lines changed

8 files changed

+40
-42
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ new Vue({
9494
:--- | :--- | :--- | :--- |
9595
| size | Number || Each list item height, currently only supports fixed height. |
9696
| remain | Number || How many items except show in virtual-list viewport, so `size` and `remian` will determine the virtual-list outside container height (size × remian). |
97-
| onScroll | Function | * | Call on virtual-list scroll event hanlding, param: `(scrollTop, e)` |
97+
| klass | String | * | Add a custom classname to virtual-list component default is `virtual-scroll-list`. |
98+
| onScroll | Function | * | Call on virtual-list scroll event hanlding, param: `(e, scrollTop)` |
9899
| toTop | Event | * | An event emit by virtual-list component when the list is scrolled on top. |
99100
| toBottom | Event | * | An event emit by virtual-list component when the list is scrolled on bottom. |
100101

demo/build/finite.js

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

demo/build/finite.js.map

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

demo/build/infinite.js

Lines changed: 10 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo/build/infinite.js.map

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

demo/finite/finite.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<VirtualList :size="40" :remain="8">
3+
<VirtualList :size="50" :remain="6" :klass="'list'">
44
<Item v-for="(udf, index) of items" :index="index" :key="index" />
55
</VirtualList>
66
</div>
@@ -24,7 +24,7 @@
2424
</script>
2525

2626
<style scoped>
27-
.virtual-list {
27+
.list {
2828
border-radius: 3px;
2929
border: 1px solid #ddd;
3030
-webkit-overflow-scrolling: touch;

demo/infinite/infinite.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<VirtualList :size="40" :remain="8" v-on:toBottom="onBottom">
3+
<VirtualList :size="50" :remain="6" v-on:toBottom="onBottom">
44
<Item v-for="(udf, index) of items" :index="index" :key="index" />
55
</VirtualList>
66
</div>
@@ -34,7 +34,7 @@
3434
</script>
3535

3636
<style scoped>
37-
.virtual-list {
37+
.virtual-scroll-list {
3838
border-radius: 3px;
3939
border: 1px solid #ddd;
4040
-webkit-overflow-scrolling: touch;

src/index.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
1111
type: Number,
1212
required: true
1313
},
14+
klass: {
15+
type: String,
16+
default: 'virtual-scroll-list'
17+
},
1418
onScroll: Function
1519
},
1620

@@ -79,7 +83,7 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
7983
beforeMount () {
8084
let remains = this.remain;
8185
let delta = this.$options.delta;
82-
let benchs = Math.ceil(remains / 2);
86+
let benchs = Math.round(remains / 2);
8387

8488
delta.end = remains + benchs;
8589
delta.keeps = remains + benchs;
@@ -92,7 +96,7 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
9296

9397
return createElement('div', {
9498
'ref': 'container',
95-
'class': 'virtual-list',
99+
'class': this.klass,
96100
'style': {
97101
'overflow-y': 'auto',
98102
'height': viewHeight + 'px'
@@ -102,17 +106,11 @@ const VirtualList = Vue.component('vue-virtual-scroll-list', {
102106
}
103107
}, [
104108
createElement('div', {
105-
'ref': 'listbox',
106-
'class': 'virtual-list-box',
107-
}, [
108-
createElement('div', {
109-
'class': 'virtual-list-box-padding',
110-
'style': {
111-
'padding-top': paddingTop + 'px',
112-
'padding-bottom': (allPadding - paddingTop) + 'px'
113-
}
114-
}, showList)
115-
])
109+
'style': {
110+
'padding-top': paddingTop + 'px',
111+
'padding-bottom': allPadding - paddingTop + 'px'
112+
}
113+
}, showList)
116114
]);
117115
}
118116
});

0 commit comments

Comments
 (0)