mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Swipe): active may outrange when initialize (#8061)
This commit is contained in:
parent
1644fc1338
commit
8ac3f43189
@ -81,12 +81,10 @@ export default createComponent({
|
|||||||
|
|
||||||
const resize = () => {
|
const resize = () => {
|
||||||
if (swipeRef.value) {
|
if (swipeRef.value) {
|
||||||
const { startPosition } = props;
|
|
||||||
swipeRef.value.state.active = +startPosition;
|
|
||||||
swipeRef.value.resize();
|
|
||||||
const rect = swipeRef.value.$el.getBoundingClientRect();
|
const rect = swipeRef.value.$el.getBoundingClientRect();
|
||||||
state.rootWidth = rect.width;
|
state.rootWidth = rect.width;
|
||||||
state.rootHeight = rect.height;
|
state.rootHeight = rect.height;
|
||||||
|
swipeRef.value.resize();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -244,6 +244,8 @@ export default createComponent({
|
|||||||
|
|
||||||
const rect = useRect(root);
|
const rect = useRect(root);
|
||||||
|
|
||||||
|
active = Math.min(children.length - 1, active);
|
||||||
|
|
||||||
state.rect = rect;
|
state.rect = rect;
|
||||||
state.swiping = true;
|
state.swiping = true;
|
||||||
state.active = active;
|
state.active = active;
|
||||||
@ -381,8 +383,7 @@ export default createComponent({
|
|||||||
watch(
|
watch(
|
||||||
() => children.length,
|
() => children.length,
|
||||||
() => {
|
() => {
|
||||||
const active = Math.min(children.length - 1, state.active);
|
initialize(state.active);
|
||||||
initialize(active);
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user