chore(Swipe): use relation

This commit is contained in:
chenjiahan
2020-09-26 11:05:39 +08:00
parent 75a8a394ca
commit c175cdd2bb
2 changed files with 22 additions and 19 deletions
+7 -7
View File
@@ -1,7 +1,6 @@
import {
ref,
watch,
provide,
reactive,
computed,
onMounted,
@@ -18,10 +17,11 @@ import { doubleRaf } from '../utils/dom/raf';
import { preventDefault } from '../utils/dom/event';
// Composition
import { useTouch } from '../composition/use-touch';
import { useRect } from '../composition/use-rect';
import { useExpose } from '../composition/use-expose';
import { usePageVisibility, useWindowSize } from '@vant/use';
import { useRect } from '../composition/use-rect';
import { useTouch } from '../composition/use-touch';
import { useExpose } from '../composition/use-expose';
import { useChildren } from '../composition/use-relation';
const [createComponent, bem] = createNamespace('swipe');
@@ -73,10 +73,10 @@ export default createComponent({
active: 0,
swiping: false,
});
const children = reactive([]);
const touch = useTouch();
const windowSize = useWindowSize();
const { children, linkChildren } = useChildren(SWIPE_KEY);
const count = computed(() => children.length);
@@ -370,9 +370,9 @@ export default createComponent({
swipeTo,
});
provide(SWIPE_KEY, { size, props, count, children, activeIndicator });
linkChildren({ size, props, count, activeIndicator });
watch([children, () => props.initialSwipe], initialize);
watch([() => children.length, () => props.initialSwipe], initialize);
watch(
() => props.autoplay,