export default {
data () {
return {
cb: null
};
},
methods: {
execScrollBottomFun () {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
if (scrollTop + windowHeight === scrollHeight) {
this.cb();
}
},
addCb (cb) {
this.cb = cb;
window.addEventListener('scroll', this.execScrollBottomFun);
},
removeCb () {
this.cb = null;
window.removeEventListener('scroll', this.execScrollBottomFun);
}
},
beforeDestroy () {
this.removeCb();
}
};