...
|
...
|
@@ -6,8 +6,9 @@ |
|
|
v-for="(item, index) in visibleItems"
|
|
|
:key="index"
|
|
|
class="cube-recycle-list-item"
|
|
|
:class="thumbClass"
|
|
|
:ref="'loads'+index"
|
|
|
:style="{transform: 'translate(0,' + item.top + 'px)', 'z-index': visibleItems.length - index}"
|
|
|
:style="{transform: isThumb ? void 0 : 'translate(0,' + item.top + 'px)', 'z-index': visibleItems.length - index}"
|
|
|
>
|
|
|
<div
|
|
|
v-if="infinite"
|
...
|
...
|
@@ -61,7 +62,6 @@ |
|
|
import CubeLoading from 'cube-ui/src/components/loading/loading.vue';
|
|
|
|
|
|
const EVENT_SCROLL = 'scroll';
|
|
|
const EVENT_RESIZE = 'resize';
|
|
|
|
|
|
export default {
|
|
|
name: 'RecycleList',
|
...
|
...
|
@@ -74,7 +74,8 @@ export default { |
|
|
currentIndex: 0,
|
|
|
loadings: [],
|
|
|
startOffset: 0,
|
|
|
noMore: false
|
|
|
noMore: false,
|
|
|
thumbsList: this.thumbs,
|
|
|
};
|
|
|
},
|
|
|
props: {
|
...
|
...
|
@@ -93,19 +94,38 @@ export default { |
|
|
onFetch: {
|
|
|
type: Function,
|
|
|
required: true
|
|
|
},
|
|
|
thumbs: {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return [];
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
visibleItems() {
|
|
|
const items = this.items.slice(Math.max(0, this.startIndex - this.size), Math.min(this.items.length, this.startIndex + this.size));
|
|
|
|
|
|
return items;
|
|
|
if (this.thumbsList.length) {
|
|
|
return this.thumbsList.map(item => {
|
|
|
return {
|
|
|
data: item
|
|
|
};
|
|
|
});
|
|
|
}
|
|
|
return this.items.slice(Math.max(0, this.startIndex - this.size), Math.min(this.items.length, this.startIndex + this.size));
|
|
|
},
|
|
|
tombHeight() {
|
|
|
return this.infinite ? this.$refs.tomb && this.$refs.tomb.offsetHeight : 0;
|
|
|
},
|
|
|
loading() {
|
|
|
return this.loadings.length;
|
|
|
return this.loadings.length && this.isThumb;
|
|
|
},
|
|
|
isThumb() {
|
|
|
return !!this.thumbsList.length;
|
|
|
},
|
|
|
thumbClass() {
|
|
|
return {
|
|
|
thumb: this.isThumb
|
|
|
};
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
...
|
...
|
@@ -159,7 +179,6 @@ export default { |
|
|
if (reload) {
|
|
|
this.noMore = false;
|
|
|
this.list = [];
|
|
|
this.items = [];
|
|
|
}
|
|
|
this.loadings.push('pending');
|
|
|
this.onFetch().then((res) => {
|
...
|
...
|
@@ -190,6 +209,9 @@ export default { |
|
|
}));
|
|
|
}
|
|
|
window.Promise.all(promiseTasks).then(() => {
|
|
|
if (this.thumbsList.length) {
|
|
|
this.thumbsList = [];
|
|
|
}
|
|
|
this.updateItemTop();
|
|
|
});
|
|
|
},
|
...
|
...
|
@@ -311,6 +333,8 @@ export default { |
|
|
width: 100%
|
|
|
position: absolute
|
|
|
box-sizing: border-box
|
|
|
&.thumb
|
|
|
position relative
|
|
|
.cube-recycle-list-transition
|
|
|
position: absolute
|
|
|
opacity: 0
|
...
|
...
|
|