Skip to content

Commit c43ca8e

Browse files
committed
Update
1 parent c01edaf commit c43ca8e

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

dist/index.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,28 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
116116
default: function _default() {}
117117
}
118118
},
119-
// use alter to identify which prop change.
119+
// use changeProp to identify which prop change.
120120
watch: {
121121
size: function size() {
122-
this.alter = 'size';
122+
this.changeProp = 'size';
123123
},
124124
remain: function remain() {
125-
this.alter = 'remain';
125+
this.changeProp = 'remain';
126126
},
127127
bench: function bench() {
128-
this.alter = 'bench';
128+
this.changeProp = 'bench';
129129
this.itemModeForceRender();
130130
},
131131
start: function start() {
132-
this.alter = 'start';
132+
this.changeProp = 'start';
133133
this.itemModeForceRender();
134134
},
135135
offset: function offset() {
136-
this.alter = 'offset';
136+
this.changeProp = 'offset';
137137
this.itemModeForceRender();
138138
},
139139
itemcount: function itemcount() {
140-
this.alter = 'itemcount';
140+
this.changeProp = 'itemcount';
141141
this.itemModeForceRender();
142142
}
143143
},
@@ -183,17 +183,17 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
183183
beforeUpdate: function beforeUpdate() {
184184
var delta = this.delta;
185185
delta.keeps = this.remain + (this.bench || this.remain);
186-
var calcstart = this.alter === 'start' ? this.start : delta.start;
186+
var calcstart = this.changeProp === 'start' ? this.start : delta.start;
187187
var zone = this.getZone(calcstart); // if start, size or offset change, update scroll position.
188188

189-
if (this.alter && ['start', 'size', 'offset'].includes(this.alter)) {
190-
var scrollTop = this.alter === 'offset' ? this.offset : this.variable ? this.getVarOffset(zone.isLast ? delta.total : zone.start) : zone.isLast && delta.total - calcstart <= this.remain ? delta.total * this.size : calcstart * this.size;
189+
if (this.changeProp && ['start', 'size', 'offset'].includes(this.changeProp)) {
190+
var scrollTop = this.changeProp === 'offset' ? this.offset : this.variable ? this.getVarOffset(zone.isLast ? delta.total : zone.start) : zone.isLast && delta.total - calcstart <= this.remain ? delta.total * this.size : calcstart * this.size;
191191
this.$nextTick(this.setScrollTop.bind(this, scrollTop));
192192
} // if points out difference, force update once again.
193193

194194

195-
if (this.alter || delta.end !== zone.end || calcstart !== zone.start) {
196-
this.alter = '';
195+
if (this.changeProp || delta.end !== zone.end || calcstart !== zone.start) {
196+
this.changeProp = '';
197197
delta.end = zone.end;
198198
delta.start = zone.start;
199199
this.forceRender();
@@ -473,9 +473,11 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
473473
}
474474
},
475475
render: function render(h) {
476-
var list = this.filter(h);
477-
var delta = this.delta;
478476
var dbc = this.debounce;
477+
var list = this.filter(h);
478+
var _this$delta = this.delta,
479+
paddingTop = _this$delta.paddingTop,
480+
paddingBottom = _this$delta.paddingBottom;
479481
return h(this.rtag, {
480482
'ref': 'vsl',
481483
'style': {
@@ -489,8 +491,8 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
489491
}, [h(this.wtag, {
490492
'style': {
491493
'display': 'block',
492-
'padding-top': delta.paddingTop + 'px',
493-
'padding-bottom': delta.paddingBottom + 'px'
494+
'padding-top': paddingTop + 'px',
495+
'padding-bottom': paddingBottom + 'px'
494496
},
495497
'class': this.wclass,
496498
'attrs': {

src/index.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,28 +105,28 @@
105105
}
106106
},
107107

108-
// use alter to identify which prop change.
108+
// use changeProp to identify which prop change.
109109
watch: {
110110
size () {
111-
this.alter = 'size'
111+
this.changeProp = 'size'
112112
},
113113
remain () {
114-
this.alter = 'remain'
114+
this.changeProp = 'remain'
115115
},
116116
bench () {
117-
this.alter = 'bench'
117+
this.changeProp = 'bench'
118118
this.itemModeForceRender()
119119
},
120120
start () {
121-
this.alter = 'start'
121+
this.changeProp = 'start'
122122
this.itemModeForceRender()
123123
},
124124
offset () {
125-
this.alter = 'offset'
125+
this.changeProp = 'offset'
126126
this.itemModeForceRender()
127127
},
128128
itemcount () {
129-
this.alter = 'itemcount'
129+
this.changeProp = 'itemcount'
130130
this.itemModeForceRender()
131131
}
132132
},
@@ -167,12 +167,12 @@
167167
let delta = this.delta
168168
delta.keeps = this.remain + (this.bench || this.remain)
169169

170-
const calcstart = this.alter === 'start' ? this.start : delta.start
170+
const calcstart = this.changeProp === 'start' ? this.start : delta.start
171171
const zone = this.getZone(calcstart)
172172

173173
// if start, size or offset change, update scroll position.
174-
if (this.alter && ['start', 'size', 'offset'].includes(this.alter)) {
175-
const scrollTop = this.alter === 'offset'
174+
if (this.changeProp && ['start', 'size', 'offset'].includes(this.changeProp)) {
175+
const scrollTop = this.changeProp === 'offset'
176176
? this.offset : this.variable
177177
? this.getVarOffset(zone.isLast ? delta.total : zone.start)
178178
: zone.isLast && (delta.total - calcstart <= this.remain)
@@ -183,11 +183,11 @@
183183

184184
// if points out difference, force update once again.
185185
if (
186-
this.alter ||
186+
this.changeProp ||
187187
delta.end !== zone.end ||
188188
calcstart !== zone.start
189189
) {
190-
this.alter = ''
190+
this.changeProp = ''
191191
delta.end = zone.end
192192
delta.start = zone.start
193193
this.forceRender()
@@ -489,9 +489,9 @@
489489
},
490490

491491
render (h) {
492-
const list = this.filter(h)
493-
const delta = this.delta
494492
const dbc = this.debounce
493+
const list = this.filter(h)
494+
const { paddingTop, paddingBottom } = this.delta
495495

496496
return h(this.rtag, {
497497
'ref': 'vsl',
@@ -507,8 +507,8 @@
507507
h(this.wtag, {
508508
'style': {
509509
'display': 'block',
510-
'padding-top': delta.paddingTop + 'px',
511-
'padding-bottom': delta.paddingBottom + 'px'
510+
'padding-top': paddingTop + 'px',
511+
'padding-bottom': paddingBottom + 'px'
512512
},
513513
'class': this.wclass,
514514
'attrs': {

0 commit comments

Comments
 (0)