question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto start animation.

See original GitHub issue

Description

Hi guys, I have faced the problem. I just want to animate background image when component is loaded… I wrote a couple of lines, but I don’t understand what to do next 😃

Code

import Animated, { useSharedValue } from 'react-native-reanimated';

...

const SplashScreen = ({ ready, onLoading }: SplashScreenProps) => {
	const scale =  useSharedValue(0);
	
	useEffect(() => {
		if (!ready) {
			(async () => {
				await RNSplashScreen.hideAsync();
			})()
		}
	}, [ready]);
	
	return (
		<ImageBackground
			source={picture[0]}
			style={{
				flex: 1,
				justifyContent: "flex-end"
			}}
		>
			<Animated.Image
				style={[
					{
						transform: [{ scale }],
					},
				]}
				source={picture[1]}
			/>
		</ImageBackground>
	)
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
likerncommented, Sep 22, 2020

I would not recommend to use this approach:

  const animatedOpacity = useDerivedValue(() => {
    return withTiming(opacity.value, { duration: 200 }, (isFinished) => {
      console.log(`opacity: ${opacity.value}`);
      if (isFinished) {
        if (opacity.value === 1) {
          // Here we at desired state of opacity
          setText("Hey, I'm over" )
        }
      } 
    });
  });

Because it might run the animation even before the component renders on some low-end devices or with some heavy components.

I mean for the autorun option.

Yes, I agree. I answered only on start something when animation is finished. Correct animation implementation was out of scope of my answer 😉

1reaction
terrysahaidakcommented, Sep 22, 2020

I would not recommend to use this approach:

  const animatedOpacity = useDerivedValue(() => {
    return withTiming(opacity.value, { duration: 200 }, (isFinished) => {
      console.log(`opacity: ${opacity.value}`);
      if (isFinished) {
        if (opacity.value === 1) {
          // Here we at desired state of opacity
          setText("Hey, I'm over" )
        }
      } 
    });
  });

Because it might run the animation even before the component renders on some low-end devices or with some heavy components.

I mean for the autorun option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerPoint plays animations automatically even with start on ...
Hi guys, I'm facing a weird problem with PowerPoint. I have some animations applied in one of my slides, some are set to...
Read more >
Make PowerPoint Presentation Automatic | Cedarville University
Click the [Animations] tab > From the "Advanced Animation" group, click "Animation Pane". Right-click the first animation > Select "Start With Previous". This ......
Read more >
How can I start auto start an animation without onActive, and ...
You can use the Animatable API and the LaunchedEffect composable. You don't need a boolean to start the animation. Something like:
Read more >
Auto-Animate | reveal.js
Auto -Animate 4.0.0. reveal.js can automatically animate elements across slides. All you need to do is add data-auto-animate to two adjacent slide <section> ......
Read more >
Can my PowerPoint animation start automatically? - BigMarker
How to Enable Automatic PowerPoint Animation · On your Channel, go to the Channel Settings. · On the Channel Settings page, scroll down...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found