mirror of https://github.com/ElemeFE/element
InfiniteScroll: Skip trigger event on invisible element (#17553)
* InfiniteScroll: Do not trigger event on invisible element * InfiniteScroll: Do not trigger event on invisible element2pull/17926/head
parent
0c31a0a48b
commit
6f62feed3d
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue