@@ -10,27 +10,33 @@ interface StaggeredAnimationOptions {
1010}
1111
1212export function useStaggeredAnimation ( options : StaggeredAnimationOptions = { } ) {
13- // Configuration with defaults
13+ if ( ! isClientEnvironment ) {
14+ return {
15+ animatedCount : readonly ( ref ( 0 ) ) ,
16+ error : readonly ( ref < Error | null > ( null ) ) ,
17+ isAnimating : readonly ( ref ( false ) ) ,
18+ isComplete : computed ( ( ) => false ) ,
19+ replay : ( ) => { } ,
20+ resetAnimations : ( ) => { } ,
21+ }
22+ }
23+
1424 const {
1525 selector = '.animate' ,
1626 staggerDelay = 100 ,
1727 initialDelay = 100 ,
1828 animationClass = 'show' ,
1929 } = options
2030
21- // Primary State
2231 const isAnimating = ref ( false )
2332 const animatedCount = ref ( 0 )
2433
25- // State Metadata
2634 const error = ref < Error | null > ( null )
2735
28- // Computed Properties
2936 const isComplete = computed ( ( ) =>
3037 animatedCount . value > 0 && ! isAnimating . value ,
3138 )
3239
33- // Methods
3440 const animateElements = ( ) => {
3541 try {
3642 error . value = null
@@ -80,30 +86,22 @@ export function useStaggeredAnimation(options: StaggeredAnimationOptions = {}) {
8086 setTimeout ( animateElements , initialDelay )
8187 }
8288
83- // Lifecycle Hooks
8489 onMounted ( ( ) => {
8590 setTimeout ( animateElements , initialDelay )
8691 } )
8792
88- // Watchers
8993 const route = useRoute ( )
9094 watchEffect ( ( ) => {
9195 if ( route . path ) {
9296 replay ( )
9397 }
9498 } )
9599
96- // Return public API
97100 return {
98-
99101 animatedCount : readonly ( animatedCount ) ,
100-
101102 error : readonly ( error ) ,
102- // State
103103 isAnimating : readonly ( isAnimating ) ,
104- // Computed
105104 isComplete,
106- // Methods
107105 replay,
108106 resetAnimations,
109107 }
0 commit comments