|
48 | 48 | FIXED: 'FIXED',
|
49 | 49 | DYNAMIC: 'DYNAMIC'
|
50 | 50 | };
|
51 |
| - var LEADING_BUFFER = 1; |
| 51 | + var LEADING_BUFFER = 2; |
52 | 52 |
|
53 | 53 | var Virtual = /*#__PURE__*/function () {
|
54 | 54 | function Virtual(param, updateHook) {
|
|
76 | 76 |
|
77 | 77 | this.range = Object.create(null);
|
78 | 78 |
|
79 |
| - if (this.param && !this.param.disabled) { |
| 79 | + if (this.param) { |
80 | 80 | this.checkRange(0, param.keeps - 1);
|
81 | 81 | } // benchmark test data.
|
82 | 82 | // this.__bsearchCalls = 0
|
|
100 | 100 | return range;
|
101 | 101 | }
|
102 | 102 | }, {
|
103 |
| - key: "isLower", |
104 |
| - value: function isLower() { |
| 103 | + key: "isBehind", |
| 104 | + value: function isBehind() { |
105 | 105 | return this.direction === DIRECTION_TYPE.BEHIND;
|
106 | 106 | }
|
107 | 107 | }, {
|
108 |
| - key: "isUpper", |
109 |
| - value: function isUpper() { |
| 108 | + key: "isFront", |
| 109 | + value: function isFront() { |
110 | 110 | return this.direction === DIRECTION_TYPE.FRONT;
|
111 | 111 | } // return start index offset.
|
112 | 112 |
|
|
155 | 155 | value: function handleDataSourcesChange() {
|
156 | 156 | var start = this.range.start;
|
157 | 157 |
|
158 |
| - if (this.direction === DIRECTION_TYPE.FRONT) { |
| 158 | + if (this.isFront()) { |
159 | 159 | start = start - LEADING_BUFFER;
|
160 |
| - } else if (this.direction === DIRECTION_TYPE.BEHIND) { |
| 160 | + } else if (this.isBehind()) { |
161 | 161 | start = start + LEADING_BUFFER;
|
162 | 162 | }
|
163 | 163 |
|
164 | 164 | start = Math.max(start, 0);
|
165 |
| - this.updateRange(start, this.getEndByStart(start)); |
| 165 | + this.updateRange(this.range.start, this.getEndByStart(start)); |
166 | 166 | } // when slot size change, we also need force update.
|
167 | 167 |
|
168 | 168 | }, {
|
|
174 | 174 | }, {
|
175 | 175 | key: "handleScroll",
|
176 | 176 | value: function handleScroll(offset) {
|
177 |
| - if (this.param.disabled) { |
178 |
| - return; |
179 |
| - } |
180 |
| - |
181 | 177 | this.direction = offset < this.offset ? DIRECTION_TYPE.FRONT : DIRECTION_TYPE.BEHIND;
|
182 | 178 | this.offset = offset;
|
183 | 179 |
|
|
262 | 258 | var offset = 0;
|
263 | 259 | var indexSize = 0;
|
264 | 260 |
|
265 |
| - for (var index = 0; index <= givenIndex; index++) { |
| 261 | + for (var index = 0; index < givenIndex; index++) { |
266 | 262 | // this.__getIndexOffsetCalls++
|
267 | 263 | indexSize = this.sizes.get(this.param.uniqueIds[index]);
|
268 | 264 | offset = offset + (indexSize || this.getEstimateSize());
|
|
312 | 308 | this.range.end = end;
|
313 | 309 | this.range.padFront = this.getPadFront();
|
314 | 310 | this.range.padBehind = this.getPadBehind();
|
315 |
| - |
316 |
| - if (!this.param.disabled) { |
317 |
| - this.updateHook(this.getRange()); |
318 |
| - } |
| 311 | + this.updateHook(this.getRange()); |
319 | 312 | } // return end base on start when going to a new range.
|
320 | 313 |
|
321 | 314 | }, {
|
|
591 | 584 | slotHeaderSize: 0,
|
592 | 585 | slotFooterSize: 0,
|
593 | 586 | keeps: this.keeps,
|
594 |
| - disabled: this.disabled, |
595 | 587 | buffer: Math.round(this.keeps / 3),
|
596 | 588 | // recommend for a third of keeps.
|
597 | 589 | uniqueIds: this.getUniqueIdFromDataSources()
|
|
670 | 662 | // ref element is definitely available here.
|
671 | 663 | var root = this.$refs.root;
|
672 | 664 | var range = this.virtual.getRange();
|
673 |
| - var isLower = this.virtual.isLower(); |
674 |
| - var isUpper = this.virtual.isUpper(); |
| 665 | + var isFront = this.virtual.isFront(); |
| 666 | + var isBehind = this.virtual.isBehind(); |
675 | 667 | var offsetShape = root[this.isHorizontal ? 'clientWidth' : 'clientHeight'];
|
676 | 668 | var scrollShape = root[this.isHorizontal ? 'scrollWidth' : 'scrollHeight'];
|
677 | 669 |
|
678 |
| - if (isUpper && !!this.dataSources.length && offset - this.upperThreshold <= 0) { |
| 670 | + if (isFront && !!this.dataSources.length && offset - this.upperThreshold <= 0) { |
679 | 671 | this.$emit('totop', evt, range);
|
680 |
| - } else if (isLower && offset + offsetShape + this.lowerThreshold >= scrollShape) { |
| 672 | + } else if (isBehind && offset + offsetShape + this.lowerThreshold >= scrollShape) { |
681 | 673 | this.$emit('tobottom', evt, range);
|
682 | 674 | } else {
|
683 | 675 | this.$emit('scroll', evt, range);
|
|
718 | 710 | var _this$$slots = this.$slots,
|
719 | 711 | header = _this$$slots.header,
|
720 | 712 | footer = _this$$slots.footer;
|
721 |
| - var padding = this.isHorizontal ? "0px ".concat(this.range.padBehind, "px 0px ").concat(this.range.padFront, "px") : "".concat(this.range.padFront, "px 0px ").concat(this.range.padBehind, "px"); |
| 713 | + var padding = this.disabled ? 0 : this.isHorizontal ? "0px ".concat(this.range.padBehind, "px 0px ").concat(this.range.padFront, "px") : "".concat(this.range.padFront, "px 0px ").concat(this.range.padBehind, "px"); |
722 | 714 | return h(this.rootTag, {
|
723 | 715 | ref: 'root',
|
724 | 716 | on: {
|
|
0 commit comments