@@ -165,15 +165,18 @@ export function changeFigure(sentence: ISentence): IPerform {
165165 dispatch ( stageActions . setFigureMetaData ( [ deleteKey , 'zIndex' , 0 , true ] ) ) ;
166166 dispatch ( stageActions . setFigureMetaData ( [ deleteKey2 , 'zIndex' , 0 , true ] ) ) ;
167167 }
168+
168169 const setAnimationNames = ( key : string , sentence : ISentence ) => {
169170 // 处理 transform 和 默认 transform
170171 const transformString = getSentenceArgByKey ( sentence , 'transform' ) ;
171172 const durationFromArg = getSentenceArgByKey ( sentence , 'duration' ) ;
172173 const ease = getSentenceArgByKey ( sentence , 'ease' ) ?. toString ( ) ?? '' ;
173- if ( durationFromArg && typeof durationFromArg === 'number' ) {
174+ let animationObj : AnimationFrame [ ] ;
175+
176+ if ( typeof durationFromArg === 'number' && ! isNaN ( durationFromArg ) ) {
174177 duration = durationFromArg ;
175178 }
176- let animationObj : AnimationFrame [ ] ;
179+
177180 if ( transformString ) {
178181 console . log ( transformString ) ;
179182 try {
@@ -186,6 +189,11 @@ export function changeFigure(sentence: ISentence): IPerform {
186189 WebGAL . animationManager . addAnimation ( newAnimation ) ;
187190 duration = getAnimateDuration ( animationName ) ;
188191 WebGAL . animationManager . nextEnterAnimationName . set ( key , animationName ) ;
192+
193+ let exitAnimationObj = [ ...animationObj ] . reverse ( ) ;
194+ exitAnimationObj [ 0 ] . alpha = 1 ;
195+ const exitAnimationName = ( Math . random ( ) * 10 ) . toString ( 16 ) ;
196+ WebGAL . animationManager . nextExitAnimationName . set ( key + '-off' , exitAnimationName ) ;
189197 } catch ( e ) {
190198 // 解析都错误了,歇逼吧
191199 applyDefaultTransform ( ) ;
@@ -205,7 +213,13 @@ export function changeFigure(sentence: ISentence): IPerform {
205213 WebGAL . animationManager . addAnimation ( newAnimation ) ;
206214 duration = getAnimateDuration ( animationName ) ;
207215 WebGAL . animationManager . nextEnterAnimationName . set ( key , animationName ) ;
216+
217+ let exitAnimationObj = [ ...animationObj ] . reverse ( ) ;
218+ exitAnimationObj [ 0 ] . alpha = 1 ;
219+ const exitAnimationName = ( Math . random ( ) * 10 ) . toString ( 16 ) ;
220+ WebGAL . animationManager . nextExitAnimationName . set ( key + '-off' , exitAnimationName ) ;
208221 }
222+
209223 const enterAnim = getSentenceArgByKey ( sentence , 'enter' ) ;
210224 const exitAnim = getSentenceArgByKey ( sentence , 'exit' ) ;
211225 if ( enterAnim ) {
@@ -217,6 +231,7 @@ export function changeFigure(sentence: ISentence): IPerform {
217231 duration = getAnimateDuration ( exitAnim . toString ( ) ) ;
218232 }
219233 } ;
234+
220235 if ( isFreeFigure ) {
221236 /**
222237 * 下面的代码是设置自由立绘的
0 commit comments