InfiniteScroll: Skip trigger event on invisible element (#17553)

* InfiniteScroll: Do not trigger event on invisible element

* InfiniteScroll: Do not trigger event on invisible element2
pull/17926/head
iamkun 2019-10-31 15:08:52 +08:00 committed by Zhi Cun
parent 0c31a0a48b
commit 6f62feed3d
2 changed files with 29 additions and 0 deletions

View File

@ -92,6 +92,9 @@ const handleScroll = function(cb) {
if (disabled) return;
const containerInfo = container.getBoundingClientRect();
if (!containerInfo.width && !containerInfo.height) return;
let shouldTrigger = false;
if (container === el) {

View File

@ -28,5 +28,31 @@ describe('InfiniteScroll', () => {
await wait();
expect(vm.$el.innerText.indexOf('2') > -1).to.be.true;
});
it('invisible element not trigger', async() => {
vm = createVue({
template: `
<div v-show="false">
<ul ref="scrollTarget" v-infinite-scroll="load" style="height: 300px;overflow: auto;">
<li v-for="i in count" style="display: flex;height: 50px;">{{ i }}</li>
</ul>
</div>
`,
data() {
return {
count: 0
};
},
methods: {
load() {
this.count += 2;
}
}
}, true);
vm.$refs.scrollTarget.scrollTop = 2000;
await wait();
expect(vm.$el.innerText.indexOf('2') > -1).to.be.false;
});
});