Skip to content

Commit aa25f0c

Browse files
committed
Support wstyle prop #153
1 parent de4bd27 commit aa25f0c

File tree

9 files changed

+37
-34
lines changed

9 files changed

+37
-34
lines changed

demos/item-mode/build.js

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

demos/page-mode/build.js

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

demos/scroll-element/build.js

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

demos/table-mode/build.js

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

demos/variable-height/build.js

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

demos/vfor-mode/build.js

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

dist/index.js

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
6767
type: String,
6868
"default": ''
6969
},
70+
wstyle: {
71+
type: Object,
72+
"default": function _default() {
73+
return {};
74+
}
75+
},
7076
pagemode: {
7177
type: Boolean,
7278
"default": false
@@ -98,17 +104,15 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
98104
},
99105
totop: {
100106
type: [Function, Boolean],
101-
// Boolean just disable for priviate.
102107
"default": false
103108
},
104109
tobottom: {
105110
type: [Function, Boolean],
106-
// Boolean just disable for priviate.
107111
"default": false
108112
},
109113
onscroll: {
110114
type: [Function, Boolean],
111-
// Boolean just disable for priviate.
115+
// Boolean disables default behavior
112116
"default": false
113117
},
114118
istable: {
@@ -130,7 +134,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
130134
"default": function _default() {}
131135
}
132136
},
133-
// use changeProp to identify which prop change.
137+
// use changeProp to identify the prop change.
134138
watch: {
135139
size: function size() {
136140
this.changeProp = 'size';
@@ -305,14 +309,14 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
305309
}
306310

307311
var zone = this.getZone(overs);
308-
var bench = this.bench || this.remain; // for better performance, if scroll pass items within now bench, do not update.
309-
// and if overs is going to reach last item, we should render next zone immediately.
312+
var bench = this.bench || this.remain; // for better performance, if scroll passes items within the bench, do not update.
313+
// and if it's close to the last item, render next zone immediately.
310314

311315
var shouldRenderNextZone = Math.abs(overs - delta.start - bench) === 1;
312316

313317
if (!shouldRenderNextZone && overs - delta.start <= bench && !zone.isLast && overs > delta.start) {
314318
return;
315-
} // we'd better make sure forceRender calls as less as possible.
319+
} // make sure forceRender calls as less as possible.
316320

317321

318322
if (shouldRenderNextZone || zone.start !== delta.start || zone.end !== delta.end) {
@@ -321,7 +325,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
321325
this.forceRender();
322326
}
323327
},
324-
// return the right zone info base on `start/index`.
328+
// return the right zone info based on `start/index`.
325329
getZone: function getZone(index) {
326330
var start;
327331
var delta = this.delta;
@@ -342,8 +346,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
342346
isLast: isLast
343347
};
344348
},
345-
// public method, force render ui list if we needed.
346-
// call this before the next repaint to get better performance.
349+
// public method, force render ui list if needed.
350+
// call this before the next rerender to get better performance.
347351
forceRender: function forceRender() {
348352
var _this = this;
349353

@@ -357,7 +361,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
357361
this.forceRender();
358362
}
359363
},
360-
// return the scroll passed items count in variable.
364+
// return the scroll of passed items count in variable.
361365
getVarOvers: function getVarOvers(offset) {
362366
var low = 0;
363367
var middle = 0;
@@ -432,27 +436,27 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
432436

433437
return 0;
434438
},
435-
// return the variable paddingTop base current zone.
439+
// return the variable paddingTop based on current zone.
436440
// @todo: if set a large `start` before variable was calculated,
437441
// here will also case too much offset calculate when list is very large,
438442
// consider use estimate paddingTop in this case just like `getVarPaddingBottom`.
439443
getVarPaddingTop: function getVarPaddingTop() {
440444
return this.getVarOffset(this.delta.start);
441445
},
442-
// return the variable paddingBottom base current zone.
446+
// return the variable paddingBottom based on the current zone.
443447
getVarPaddingBottom: function getVarPaddingBottom() {
444448
var delta = this.delta;
445449
var last = delta.total - 1;
446450

447451
if (delta.total - delta.end <= delta.keeps || delta.varLastCalcIndex === last) {
448452
return this.getVarOffset(last) - this.getVarOffset(delta.end);
449453
} else {
450-
// if unreached last zone or uncalculate real behind offset
451-
// return the estimate paddingBottom avoid too much calculate.
454+
// if unreached last zone or uncalculated real behind offset
455+
// return the estimate paddingBottom and avoid too much calculations.
452456
return (delta.total - delta.end) * (delta.varAverSize || this.size);
453457
}
454458
},
455-
// retun the variable all heights use to judge reach bottom.
459+
// return the variable all heights use to judge reach bottom.
456460
getVarAllHeight: function getVarAllHeight() {
457461
var delta = this.delta;
458462

@@ -464,7 +468,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
464468
},
465469
// public method, allow the parent update variable by index.
466470
updateVariable: function updateVariable(index) {
467-
// clear/update all the offfsets and heights ahead of index.
471+
// clear/update all the offsets and heights ahead of index.
468472
this.getVarOffset(index, true);
469473
},
470474
// trigger a props event on parent.
@@ -487,10 +491,10 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
487491
}
488492
}
489493
},
490-
// filter the shown items base on `start` and `end`.
494+
// filter the shown items based on `start` and `end`.
491495
filter: function filter(h) {
492496
var delta = this.delta;
493-
var slots = this.$slots["default"] || []; // item-mode shoud judge from items prop.
497+
var slots = this.$slots["default"] || []; // item-mode should be decided from items prop.
494498

495499
if (this.item || this.$scopedSlots.item) {
496500
delta.total = this.itemcount;
@@ -560,16 +564,16 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
560564
}
561565

562566
var renderList = h(wtag, {
563-
style: {
567+
style: Object.assign({
564568
display: 'block',
565569
'padding-top': paddingTop + 'px',
566570
'padding-bottom': paddingBottom + 'px'
567-
},
571+
}, this.wstyle),
568572
"class": this.wclass,
569573
attrs: {
570574
role: 'group'
571575
}
572-
}, list); // page mode just render list, no wraper.
576+
}, list); // page mode just render list, no wrapper.
573577

574578
if (this.pagemode || this.scrollelement) {
575579
return renderList;
@@ -579,7 +583,7 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
579583
ref: 'vsl',
580584
style: {
581585
display: 'block',
582-
'overflow-y': this.size >= this.remain ? 'auto' : 'inital',
586+
'overflow-y': this.size >= this.remain ? 'auto' : 'initial',
583587
height: this.size * this.remain + 'px'
584588
},
585589
on: {

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.4.3",
3+
"version": "1.4.4",
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: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,11 @@
574574
list = [h('table', [h('tbody', list)])]
575575
}
576576
const renderList = h(wtag, {
577-
style: {
577+
style: Object.assign({
578578
display: 'block',
579579
'padding-top': paddingTop + 'px',
580-
'padding-bottom': paddingBottom + 'px',
581-
...this.wstyle
582-
},
580+
'padding-bottom': paddingBottom + 'px'
581+
}, this.wstyle),
583582
class: this.wclass,
584583
attrs: {
585584
role: 'group'

0 commit comments

Comments
 (0)