Skip to content

Commit c28a14c

Browse files
committed
Version bump
1 parent bbbc8e3 commit c28a14c

File tree

4 files changed

+86
-54
lines changed

4 files changed

+86
-54
lines changed

dist/vue-virtual-scroller.esm.js

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { clearTimeout, setTimeout } from 'timers';
2-
31
function getInternetExplorerVersion() {
42
var ua = window.navigator.userAgent;
53

@@ -216,6 +214,10 @@ var Scroller = {
216214
type: [Number, String],
217215
default: null
218216
},
217+
minItemHeight: {
218+
type: [Number, String],
219+
default: null
220+
},
219221
heightField: {
220222
type: String,
221223
default: 'height'
@@ -251,14 +253,17 @@ var Scroller = {
251253
heights: function heights() {
252254
if (this.itemHeight === null) {
253255
var heights = {
254-
'-1': 0
256+
'-1': { accumulator: 0 }
255257
};
256258
var items = this.items;
257259
var field = this.heightField;
260+
var minItemHeight = this.minItemHeight;
258261
var accumulator = 0;
262+
var current = void 0;
259263
for (var i = 0, l = items.length; i < l; i++) {
260-
accumulator += items[i][field];
261-
heights[i] = accumulator;
264+
current = items[i][field] || minItemHeight;
265+
accumulator += current;
266+
heights[i] = { accumulator: accumulator, height: current };
262267
}
263268
return heights;
264269
}
@@ -323,7 +328,7 @@ var Scroller = {
323328
scrollToItem: function scrollToItem(index) {
324329
var scrollTop = void 0;
325330
if (this.itemHeight === null) {
326-
scrollTop = index > 0 ? this.heights[index - 1] : 0;
331+
scrollTop = index > 0 ? this.heights[index - 1].accumulator : 0;
327332
} else {
328333
scrollTop = index * this.itemHeight;
329334
}
@@ -486,10 +491,10 @@ var VirtualScroller = { render: function render() {
486491
// Searching for startIndex
487492
do {
488493
oldI = i;
489-
h = heights[i];
494+
h = heights[i].accumulator;
490495
if (h < scrollTop) {
491496
a = i;
492-
} else if (i < l && heights[i + 1] > scrollTop) {
497+
} else if (i < l && heights[i + 1].accumulator > scrollTop) {
493498
b = i;
494499
}
495500
i = ~~((a + b) / 2);
@@ -498,11 +503,11 @@ var VirtualScroller = { render: function render() {
498503
startIndex = i;
499504

500505
// For containers style
501-
offsetTop = i > 0 ? heights[i - 1] : 0;
502-
containerHeight = heights[l - 1];
506+
offsetTop = i > 0 ? heights[i - 1].accumulator : 0;
507+
containerHeight = heights[l - 1].accumulator;
503508

504509
// Searching for endIndex
505-
for (endIndex = i; endIndex < l && heights[endIndex] < scrollBottom; endIndex++) {}
510+
for (endIndex = i; endIndex < l && heights[endIndex].accumulator < scrollBottom; endIndex++) {}
506511
if (endIndex === -1) {
507512
endIndex = items.length - 1;
508513
} else {
@@ -594,8 +599,8 @@ var RecycleList = { render: function render() {
594599
var _vm = this;var _h = _vm.$createElement;var _c = _vm._self._c || _h;return _c('div', { directives: [{ name: "observe-visibility", rawName: "v-observe-visibility", value: _vm.handleVisibilityChange, expression: "handleVisibilityChange" }], staticClass: "recycle-list", class: _vm.cssClass, on: { "&scroll": function scroll($event) {
595600
_vm.handleScroll($event);
596601
} } }, [_c('div', { staticClass: "item-wrapper", style: { height: _vm.totalHeight + 'px' } }, _vm._l(_vm.pool, function (view) {
597-
return _c('div', { key: view.nr.id, staticClass: "item-view", style: { transform: 'translateY(' + view.top + 'px)' } }, [_vm._t("default", null, { item: view.item })], 2);
598-
})), _vm._v(" "), _c('resize-observer', { on: { "notify": _vm.handleResize } })], 1);
602+
return _c('div', { key: view.nr.id, staticClass: "item-view", style: { transform: 'translateY(' + view.top + 'px)' } }, [_vm._t("default", null, { item: view.item, active: view.nr.used })], 2);
603+
})), _vm._v(" "), _vm._t("after-container"), _vm._v(" "), _c('resize-observer', { on: { "notify": _vm.handleResize } })], 2);
599604
}, staticRenderFns: [], _scopeId: 'data-v-2277f571',
600605
name: 'RecycleList',
601606

@@ -630,10 +635,15 @@ var RecycleList = { render: function render() {
630635
checkItem: false
631636
});
632637
},
633-
heights: function heights() {
634-
this.updateVisibleItems({
635-
checkItem: false
636-
});
638+
639+
heights: {
640+
handler: function handler() {
641+
this.updateVisibleItems({
642+
checkItem: false
643+
});
644+
},
645+
646+
deep: true
637647
}
638648
},
639649

@@ -691,7 +701,7 @@ var RecycleList = { render: function render() {
691701
unusedPool.push(view);
692702
if (!fake) {
693703
view.nr.used = false;
694-
view.top = this.totalHeight;
704+
view.top = -9999;
695705
this.$_views.delete(view.item);
696706
}
697707
},
@@ -768,10 +778,10 @@ var RecycleList = { render: function render() {
768778
// Searching for startIndex
769779
do {
770780
oldI = i;
771-
h = heights[i];
781+
h = heights[i].accumulator;
772782
if (h < scroll.top) {
773783
a = i;
774-
} else if (i < count && heights[i + 1] > scroll.top) {
784+
} else if (i < count && heights[i + 1].accumulator > scroll.top) {
775785
b = i;
776786
}
777787
i = ~~((a + b) / 2);
@@ -780,10 +790,10 @@ var RecycleList = { render: function render() {
780790
startIndex = i;
781791

782792
// For container style
783-
totalHeight = heights[count - 1];
793+
totalHeight = heights[count - 1].accumulator;
784794

785795
// Searching for endIndex
786-
for (endIndex = i; endIndex < count && heights[endIndex] < scroll.bottom; endIndex++) {}
796+
for (endIndex = i; endIndex < count && heights[endIndex].accumulator < scroll.bottom; endIndex++) {}
787797
if (endIndex === -1) {
788798
endIndex = items.length - 1;
789799
} else {
@@ -847,6 +857,11 @@ var RecycleList = { render: function render() {
847857
item = items[_i3];
848858
view = views.get(item);
849859

860+
if (!itemHeight && !heights[_i3].height) {
861+
if (view) this.unuseView(view);
862+
continue;
863+
}
864+
850865
// No view assigned to item
851866
if (!view) {
852867
type = item[typeField];
@@ -887,7 +902,7 @@ var RecycleList = { render: function render() {
887902

888903
// Update position
889904
if (itemHeight === null) {
890-
view.top = heights[_i3 - 1];
905+
view.top = heights[_i3 - 1].accumulator;
891906
} else {
892907
view.top = _i3 * itemHeight;
893908
}
@@ -912,7 +927,7 @@ function registerComponents(Vue, prefix) {
912927

913928
var plugin$4 = {
914929
// eslint-disable-next-line no-undef
915-
version: "0.11.1",
930+
version: "0.11.2",
916931
install: function install(Vue, options) {
917932
var finalOptions = Object.assign({}, {
918933
installComponents: true,

0 commit comments

Comments
 (0)