...
|
...
|
@@ -20,14 +20,13 @@ export default { |
|
|
computed: {
|
|
|
...mapState(['yoho'])
|
|
|
},
|
|
|
|
|
|
// watch: {
|
|
|
// ['yoho.visible'](visible) {
|
|
|
// if (visible) {
|
|
|
// this.checkReport();
|
|
|
// }
|
|
|
// }
|
|
|
// },
|
|
|
watch: {
|
|
|
['yoho.pageVisible'](visible) {
|
|
|
if (visible) {
|
|
|
this.checkReport(void 0, true);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
this.scrollEvent = throttle(50, this.checkReport);
|
|
|
if (_.get(this.$parent, '$options.name') === 'Scroller') {
|
...
|
...
|
@@ -37,7 +36,7 @@ export default { |
|
|
}
|
|
|
if (this.$scrollEl) {
|
|
|
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
|
|
|
this.checkReport();
|
|
|
this.checkReport(void 0, true);
|
|
|
}
|
|
|
},
|
|
|
destroyed() {
|
...
|
...
|
@@ -46,11 +45,11 @@ export default { |
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
checkReport() {
|
|
|
checkReport(evt, isInit) {
|
|
|
_.each(this.$children, (component, index) => {
|
|
|
const visiable = this.isVisiable(component.$el, this.$scrollEl);
|
|
|
|
|
|
if (visiable && this.componentStatus[index] !== visiable) {
|
|
|
if (visiable && (this.componentStatus[index] !== visiable || isInit)) {
|
|
|
this.report(component, index + 1);
|
|
|
}
|
|
|
this.componentStatus[index] = visiable;
|
...
|
...
|
|