11<template >
2- <AnimateSequence
3- ref="sequenceRef "
2+ <AnimateHandler
3+ ref="handlerRef "
44 :style =" { opacity: 0 } "
55 class="relative top-0 left-0 w-full h-full"
66 :init-sequence =" (): AnimationSequence => [
1414 [' .main-intro-text' , { opacity: [0 , 1 ], x: [- 50 , 0 ] }, { duration: 0.3 , delay: stagger (0.1 ), at: ' +0.3' , type: ' spring' }],
1515 [' .minor-intro-text' , { opacity: [0 , 1 ], y: [200 , 0 ] }, { duration: 0.5 , at: ' +0.4' , type: ' spring' }],
1616 [thirdLine , { opacity: [0 , 1 ], x: [- 100 , 0 ] }, { duration: 1 , at: ' <' }],
17- [thirdLine , { strokeDashoffset: [0 , - 15 ] }, { duration: 1 , at: ' -0.05' , repeat: 10 , ease: ' linear' }],
1817 ] "
1918 :exit-sequence =" (): AnimationSequence => [
20- [thirdLine , { opacity: [1 , 0 ], x: [0 , 100 ] }, { duration: 1 , at: ' - 0.05' }],
19+ [thirdLine , { opacity: [1 , 0 ], x: [0 , 100 ] }, { duration: 1 , at: ' 0.05' }],
2120 [' .main-intro-text' , { opacity: [1 , 0 ], x: [0 , - 50 ] }, { duration: 0.3 , at: ' +0.2' }],
2221 [' .minor-intro-text' , { opacity: [1 , 0 ], y: [0 , 50 ] }, { duration: 0.3 , at: ' +0.1' }],
2322 [imgBox1 , { opacity: [1 , 0 ], y: [0 , - 200 ], scale: [1 , 0.4 ] }, { duration: 0.4 , at: ' +0.2' }],
2423 ] "
24+ :exit-delay =" 10000 "
2525 @init-complete =" console .log (' Init Complete' )"
26- @enter-start =" () => console .log (' Enter Start' ) "
26+ @enter-start =" () => {
27+ console .log (' Enter Start' )
28+ animate (thirdLine , { strokeDashoffset: [0 , - 15 ] }, { duration: 1 , repeat: Infinity , ease: ' linear' });
29+ } "
2730 @enter-complete =" console .log (' Enter Complete' )"
2831 @exit-start =" console .log (' Exit Start' )"
2932 @exit-complete =" console .log (' Exit Complete' ); emit (' onComplete' )"
5861 一个占位用的,以后存放图片
5962 </div >
6063 </div >
61- </AnimateSequence >
64+ </AnimateHandler >
6265</template >
6366
6467<script setup lang="ts">
6568import type { AnimationSequence } from ' motion-v' ;
66- import { stagger } from ' motion-v' ;
67- import AnimateSequence from ' ./AnimateSequence.vue' ;
69+ import { animate , stagger } from ' motion-v' ;
70+ import { useAnimationHandler } from ' ~/composables/useAnimationHandler' ;
71+ import AnimateHandler from ' ./AnimateHandler.vue' ;
6872
6973defineProps <{
7074 title1: string ;
@@ -75,18 +79,12 @@ const emit = defineEmits<{
7579 (e : ' onComplete' ): void ;
7680}>();
7781
78- const sequenceRef = ref < InstanceType < typeof AnimateSequence >> ();
82+ const { handlerRef, expose } = useAnimationHandler ();
7983const container = ref <HTMLElement >();
8084const imgBox1 = ref <HTMLElement >();
8185const thirdLine = ref <HTMLElement >();
8286
83- defineExpose ({
84- playInit : async () => sequenceRef .value ?.runInitSequence ?.(),
85- playEnter : async () => sequenceRef .value ?.runEnterSequence ?.(),
86- playExit : async () => sequenceRef .value ?.runExitSequence ?.(),
87- runFull : async () => await sequenceRef .value ?.runFullSequence ?.(),
88- getStatus : () => sequenceRef .value ?.aniStatus ,
89- });
87+ defineExpose (expose );
9088 </script >
9189
9290<!-- cosmo-only-tailwind-disable -->
0 commit comments