@@ -298,3 +298,72 @@ test('animate layout props and rerender in many components', () => {
298298 </ rn-view > ,
299299 ) ;
300300} ) ;
301+
302+ test ( 'animate width, height and opacity at once' , ( ) => {
303+ const viewRef = createRef < HostInstance > ( ) ;
304+ allowStyleProp ( 'width' ) ;
305+ allowStyleProp ( 'height' ) ;
306+
307+ let _animatedWidth ;
308+ let _animatedHeight ;
309+ let _animatedOpacity ;
310+ let _parallelAnimation ;
311+
312+ function MyApp ( ) {
313+ const animatedWidth = useAnimatedValue ( 100 ) ;
314+ const animatedHeight = useAnimatedValue ( 100 ) ;
315+ const animatedOpacity = useAnimatedValue ( 1 ) ;
316+ _animatedWidth = animatedWidth ;
317+ _animatedHeight = animatedHeight ;
318+ _animatedOpacity = animatedOpacity ;
319+ return (
320+ < Animated . View
321+ ref = { viewRef }
322+ style = { [
323+ {
324+ width : animatedWidth ,
325+ height : animatedHeight ,
326+ opacity : animatedOpacity ,
327+ } ,
328+ ] }
329+ />
330+ ) ;
331+ }
332+
333+ const root = Fantom . createRoot ( ) ;
334+
335+ Fantom . runTask ( ( ) => {
336+ root . render ( < MyApp /> ) ;
337+ } ) ;
338+
339+ Fantom . runTask ( ( ) => {
340+ _parallelAnimation = Animated . parallel ( [
341+ Animated . timing ( _animatedWidth , {
342+ toValue : 200 ,
343+ duration : 100 ,
344+ useNativeDriver : true ,
345+ } ) ,
346+ Animated . timing ( _animatedHeight , {
347+ toValue : 200 ,
348+ duration : 100 ,
349+ useNativeDriver : true ,
350+ } ) ,
351+ Animated . timing ( _animatedOpacity , {
352+ toValue : 0.5 ,
353+ duration : 100 ,
354+ useNativeDriver : true ,
355+ } ) ,
356+ ] ) . start ( ) ;
357+ } ) ;
358+
359+ Fantom . unstable_produceFramesForDuration ( 100 ) ;
360+
361+ // TODO: this shouldn't be neccessary since animation should be stopped after duration
362+ Fantom . runTask ( ( ) => {
363+ _parallelAnimation ?. stop ( ) ;
364+ } ) ;
365+
366+ expect (
367+ root . getRenderedOutput ( { props : [ 'width' , 'height' , 'opacity' ] } ) . toJSX ( ) ,
368+ ) . toEqual ( < rn-view height = "200.000000" opacity = "0.5" width = "200.000000" /> ) ;
369+ } ) ;
0 commit comments