|
@@ -28,6 +28,15 @@ |
|
@@ -28,6 +28,15 @@ |
28
|
},
|
28
|
},
|
29
|
methods: {
|
29
|
methods: {
|
30
|
checkReport() {
|
30
|
checkReport() {
|
|
|
31
|
+ // 顶部区域可能切换显示和隐藏所以动态获取
|
|
|
32
|
+ const topRect = document.querySelector(`.${this.topClassName}`).getBoundingClientRect();
|
|
|
33
|
+
|
|
|
34
|
+ // 可见区域顶部距离视口的上边的距离
|
|
|
35
|
+ this.viewArea.top = topRect.bottom;
|
|
|
36
|
+
|
|
|
37
|
+ // 可见区域底部距离视口的上边的距离
|
|
|
38
|
+ this.viewArea.bottom = window.screen.height;
|
|
|
39
|
+
|
31
|
let children = _.filter(this.$children, child => {
|
40
|
let children = _.filter(this.$children, child => {
|
32
|
return child.$options.name === 'ExposureItem'
|
41
|
return child.$options.name === 'ExposureItem'
|
33
|
});
|
42
|
});
|
|
@@ -47,19 +56,10 @@ |
|
@@ -47,19 +56,10 @@ |
47
|
},
|
56
|
},
|
48
|
mounted() {
|
57
|
mounted() {
|
49
|
let timer = setInterval(() => {
|
58
|
let timer = setInterval(() => {
|
50
|
- const filterRect = document.querySelector(`.${this.topClassName}`).getBoundingClientRect();
|
|
|
51
|
-
|
|
|
52
|
- // 可见区域顶部距离视口的上边的距离
|
|
|
53
|
- this.viewArea.top = filterRect.bottom;
|
|
|
54
|
-
|
|
|
55
|
- // 可见区域底部距离视口的上边的距离
|
|
|
56
|
- this.viewArea.bottom = window.screen.height;
|
|
|
57
|
-
|
|
|
58
|
this.$scrollEl = window;
|
59
|
this.$scrollEl = window;
|
59
|
this.scrollEvent = util.throttle(500, this.checkReport);
|
60
|
this.scrollEvent = util.throttle(500, this.checkReport);
|
60
|
if (this.$scrollEl) {
|
61
|
if (this.$scrollEl) {
|
61
|
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
|
62
|
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
|
62
|
-
|
|
|
63
|
}
|
63
|
}
|
64
|
|
64
|
|
65
|
if (this.$children.length) {
|
65
|
if (this.$children.length) {
|
|
@@ -68,7 +68,8 @@ |
|
@@ -68,7 +68,8 @@ |
68
|
}
|
68
|
}
|
69
|
}, 500);
|
69
|
}, 500);
|
70
|
|
70
|
|
71
|
- setInterval(() => {
|
71
|
+ let reportTimer = setInterval(() => {
|
|
|
72
|
+ if (!this.$children.length) { return clearInterval(reportTimer); }
|
72
|
_.each(_.filter(this.$children, child => child.$options.name === 'ExposureItem'), child => child.report());
|
73
|
_.each(_.filter(this.$children, child => child.$options.name === 'ExposureItem'), child => child.report());
|
73
|
}, 3000);
|
74
|
}, 3000);
|
74
|
}
|
75
|
}
|