fix(swipe): delay load cause swipe error (#10052) (#10069)

This commit is contained in:
chenjiangui
2021-12-28 19:57:43 +08:00
committed by GitHub
parent 8d60697ec1
commit fff5fa9fa7
+14 -4
View File
@@ -8,9 +8,10 @@ import {
onDeactivated,
onBeforeUnmount,
defineComponent,
type InjectionKey,
type CSSProperties,
nextTick,
type ExtractPropTypes,
type CSSProperties,
type InjectionKey,
} from 'vue';
// Utils
@@ -248,10 +249,11 @@ export default defineComponent({
return;
}
const cb = () => {
if (!isHidden(root)) {
const rect = {
width: root.value.offsetWidth,
height: root.value.offsetHeight,
width: root.value!.offsetWidth,
height: root.value!.offsetHeight,
};
state.rect = rect;
state.width = +(props.width ?? rect.width);
@@ -272,6 +274,14 @@ export default defineComponent({
autoplay();
};
// issue: https://github.com/youzan/vant/issues/10052
if (isHidden(root)) {
nextTick().then(cb);
} else {
cb();
}
};
const resize = () => initialize(state.active);
let touchStartTime: number;