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.

Possible to have smooth animation on progress bar?

See original GitHub issue

Is there a way to make the animation between progress changes to be smoother? It’s very choppy. I’ve tried slowing down the interval of the animation, but it falls behind. I’m using a custom hook courtesy of Dan Abramov to make sure that the timer is counting down correctly. I’m counting down by 1 second (1000 milliseconds), So I’m not sure how this could be fixed or if it’s on my end.

useInterval.js

import { useEffect, useRef } from 'react';

export default (callback, delay) => {
  const savedCallback = useRef();

  // Remember the latest callback.
  useEffect(() => {
    savedCallback.current = callback;
  }, [callback]);

  // Set up the interval.
  useEffect(() => {
    function tick() {
      savedCallback.current();
    }
    if (delay !== null) {
      const id = setInterval(tick, delay);
      return () => clearInterval(id);
    }
  }, [delay]);
};

useInterval(() => {
  if (time > 0) setTime(prevState => prevState - 1);
  else endTime();
}, 1000);


<ProgressBar
  progress={time / timer} //time and timer is some number out of a total, i.e. 10/25
  width={RFPercentage(40)}
  height={RFPercentage(1)}
  borderRadius={20}
  useNativeDriver
  animationType='spring'
  color={theme.accent}
/>

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
StanislavMayorovcommented, Sep 16, 2021

We noticed a huge js performance issue when we rerender Circle to animate progress. <Progress.Circle progress={dymanicNumber}/> So we had to replace it to animated react-native-svg with useNativeDriver.

2reactions
sentientmachin3commented, Jan 31, 2021

No, I implemented my own. It was not difficult actually, using Animated.timing you should get what you need in a hour or so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Smooth Progress Bar Animation - android
To correct this you have a few options. The first is to up your integers from 0 to someBigInt This will give the...
Read more >
Android : Smooth Progress Bar Animation - YouTube
Android : Smooth Progress Bar Animation [ Beautify Your Computer : https://www.hows.tech/p/recommended.html ] Android : Smooth Progress Bar ...
Read more >
How to Create a Smooth Animated Progress Bar
While working on a timer component I needed a smooth animated progress bar so came up with the following. It only has a...
Read more >
How to Make an Animated Progress Bar in CSS
The text of the button needs to be inline-block as we will make positional transitions on it. You also need to set transition...
Read more >
Smooth Progress Bar Animation
Smooth Progress Bar Animation ... Material Design offers two visually distinct types of progress indicators: linear and circular progress indicators. Only one ...
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