Authored by 陈峰

throttle

... ... @@ -7,6 +7,7 @@
<script>
import {REPORT_YAS} from 'store/yoho/types';
import _ from 'lodash';
import {throttle} from 'common/utils';
export default {
name: 'ResourceBox',
... ... @@ -16,13 +17,14 @@ export default {
};
},
mounted() {
this.scrollEvent = throttle(50, this.resourceScroll);
if (_.get(this.$parent, '$options.name') === 'Scroller') {
this.$scrollEl = this.$parent.$el;
} else {
this.$scrollEl = document.querySelector('.layout-content');
}
if (this.$scrollEl) {
this.$scrollEl.addEventListener('scroll', this.resouceScroll);
this.$scrollEl.addEventListener('scroll', this.scrollEvent);
_.each(this.$children, (component, index) => {
const visiable = this.isVisiable(component.$el, this.$scrollEl);
... ... @@ -35,11 +37,11 @@ export default {
},
destroyed() {
if (this.$scrollEl) {
this.$scrollEl.removeEventListener('scroll', this.resouceScroll);
this.$scrollEl.removeEventListener('scroll', this.scrollEvent);
}
},
methods: {
resouceScroll() {
resourceScroll() {
_.each(this.$children, (component, index) => {
const visiable = this.isVisiable(component.$el, this.$scrollEl);
... ... @@ -54,7 +56,6 @@ export default {
if (reportData) {
const param = {
P_PARAM: this.$route.query,
P_NAME: this.$route.name,
F_NAME: reportData.template_name,
F_ID: reportData.template_id,
... ...