@@ -11,7 +11,7 @@ import ParentComponent from './ParentComponent.vue'
1111import LoadingComponent from ' ./LoadingComponent.vue'
1212import LCARSMarkdown from ' ./LCARSMarkdown.vue'
1313import gsap from ' gsap'
14- import type { AnimationConfig } from ' @/AnimationConfig'
14+ import { applyStepAnimation , type AnimationConfig } from ' @/AnimationConfig'
1515import TextComponent from ' ./TextComponent.vue'
1616
1717const props = useAttrs ()
@@ -126,12 +126,7 @@ function triggerAnimations() {
126126 if (props .childrenAnimation ) {
127127 const animation = props .childrenAnimation as AnimationConfig
128128 if (animation .type === ' build' ) {
129- gsap .to (animated , {
130- duration: animation .duration ?? 0.1 * children .length ,
131- children: children .length ,
132- ease: ` steps(${children .length }) ` ,
133- delay: animation .delay ,
134- })
129+ applyStepAnimation (animation , children .length , animated , ' children' )
135130 }
136131 } else {
137132 animated .children = children .length
@@ -142,12 +137,7 @@ function triggerAnimations() {
142137 if (props .topChildrenAnimation ) {
143138 const animation = props .topChildrenAnimation as AnimationConfig
144139 if (animation .type === ' build' ) {
145- gsap .to (animated , {
146- duration: animation .duration ?? 0.1 * topChildren .length ,
147- top: topChildren .length ,
148- ease: ` steps(${topChildren .length }) ` ,
149- delay: animation .delay ,
150- })
140+ applyStepAnimation (animation , topChildren .length , animated , ' top' )
151141 }
152142 } else {
153143 animated .top = topChildren .length
@@ -158,12 +148,7 @@ function triggerAnimations() {
158148 if (props .bottomChildrenAnimation ) {
159149 const animation = props .bottomChildrenAnimation as AnimationConfig
160150 if (animation .type === ' build' ) {
161- gsap .to (animated , {
162- duration: animation .duration ?? 0.1 * bottomChildren .length ,
163- bottom: bottomChildren .length ,
164- ease: ` steps(${bottomChildren .length }) ` ,
165- delay: animation .delay ,
166- })
151+ applyStepAnimation (animation , bottomChildren .length , animated , ' bottom' )
167152 }
168153 } else {
169154 animated .bottom = bottomChildren .length
@@ -174,12 +159,7 @@ function triggerAnimations() {
174159 if (props .leftChildrenAnimation ) {
175160 const animation = props .leftChildrenAnimation as AnimationConfig
176161 if (animation .type === ' build' ) {
177- gsap .to (animated , {
178- duration: animation .duration ?? 0.1 * leftChildren .length ,
179- left: leftChildren .length ,
180- ease: ` steps(${leftChildren .length }) ` ,
181- delay: animation .delay ,
182- })
162+ applyStepAnimation (animation , leftChildren .length , animated , ' left' )
183163 }
184164 } else {
185165 animated .left = leftChildren .length
@@ -190,12 +170,7 @@ function triggerAnimations() {
190170 if (props .rightChildrenAnimation ) {
191171 const animation = props .rightChildrenAnimation as AnimationConfig
192172 if (animation .type === ' build' ) {
193- gsap .to (animated , {
194- duration: animation .duration ?? 0.1 * rightChildren .length ,
195- right: rightChildren .length ,
196- ease: ` steps(${rightChildren .length }) ` ,
197- delay: animation .delay ,
198- })
173+ applyStepAnimation (animation , rightChildren .length , animated , ' right' )
199174 }
200175 } else {
201176 animated .right = rightChildren .length
0 commit comments