fix(List): skip check when inside an inactive tab (#8741)

This commit is contained in:
neverland
2021-05-22 17:38:05 +08:00
committed by GitHub
parent 62a30bbf02
commit 38aeecfcb7
4 changed files with 55 additions and 11 deletions
+10 -2
View File
@@ -14,6 +14,7 @@ import { isHidden, truthProp, createNamespace } from '../utils';
// Composables
import { useRect, useScrollParent, useEventListener } from '@vant/use';
import { useExpose } from '../composables/use-expose';
import { useTabStatus } from '../composables/use-tab-status';
// Components
import { Loading } from '../loading';
@@ -50,11 +51,18 @@ export default defineComponent({
const loading = ref(false);
const root = ref<HTMLElement>();
const placeholder = ref<HTMLElement>();
const tabStatus = useTabStatus();
const scrollParent = useScrollParent(root);
const check = () => {
nextTick(() => {
if (loading.value || props.finished || props.error) {
if (
loading.value ||
props.finished ||
props.error ||
// skip check when inside an inactive tab
tabStatus?.value === false
) {
return;
}
@@ -62,7 +70,7 @@ export default defineComponent({
const scrollParentRect = useRect(scrollParent);
if (!scrollParentRect.height || isHidden(root)) {
return false;
return;
}
let isReachEdge = false;