Skip to content

Conversation

nerdmed
Copy link
Contributor

@nerdmed nerdmed commented May 29, 2017

@oblador thanks for that great lib! I have had some issues with the progress bar being jaggy while animating. Here is a suggestion that encourages the new RN native driver, i

I have tried to do the same to the circles but i get stuck with a JSON error. I think its coming from the SVG parsing or something. If you are interested to try it out see e80c8f7

@nerdmed nerdmed changed the title Add native driver support and smooth bar animation WIP - Add native driver support and smooth bar animation May 29, 2017
@nerdmed nerdmed changed the title WIP - Add native driver support and smooth bar animation Add native driver support for Bar and smooth animation May 29, 2017
@nerdmed
Copy link
Contributor Author

nerdmed commented Jun 15, 2017

@oblador any chance to merge this? Or any kind of feedback?

@MrHubble
Copy link

@nerdmed would this pull request help to address the following type of issue?

Animation in react-native-progress is done on the JS thread so anything slowing it down
will cause the animations to stutter. This should be addressed by offloading the animations
using native / declarative animation.
#35 (comment)

@nerdmed
Copy link
Contributor Author

nerdmed commented Jun 19, 2017

@MrHubble possibly yes! But i have only implemented it for the progress bar. The Circle animation code is quite harry and not straight forward to work with, but it should be also possible to implement it there.

@oblador
Copy link
Owner

oblador commented Jun 19, 2017

This is cool @nerdmed! Why did you change the animation to a timing instead of a spring?

@nerdmed
Copy link
Contributor Author

nerdmed commented Jun 19, 2017

@oblador we are using the progress bar like a real one for audio playback. As soon as you use spring easing and changing the value frequently it also stutters and looks strange. A progressbar used for imperative progress should not animate with a spring? Do you think its legit here or not really whats intended?

@oblador
Copy link
Owner

oblador commented Jul 3, 2017

OK, gotcha. However I don't want to make an unnecessary breaking change and also break my use case . Perhaps it would be better to expose some props to configure the animation? Like duration/bounciness/easing etc.

@nerdmed
Copy link
Contributor Author

nerdmed commented Jul 4, 2017

will do! I think i will find some time at the weekend!

@nerdmed nerdmed force-pushed the native-driver-support branch from 1b83cbf to d42e978 Compare July 11, 2017 15:00
@nerdmed
Copy link
Contributor Author

nerdmed commented Jul 11, 2017

@oblador alright now i have changed the way it works. Users can optionally override the animation function and config. I tried a little bit with a function as a prob but it gets quite messy and complicated to pass a function that returns a functions that takes the internal progress. What do you think of this kind of API? The current state does not change or break the behaviour compared to the old version.

@nerdmed
Copy link
Contributor Author

nerdmed commented Jul 12, 2017

@oblador here is an example how i am using it in my project with the new optional API
works like a charm and is ultra fluid as Animated.timing with linear easing is way faster

<ProgressBar
  useNativeDriver
  style={styles.progressBar}
  progress={progress}
  width={this.state.previewPlayerWidth}
  height={progressBarHeight}
  borderRadius={0}
  borderWidth={0}
  color={primary}
  unfilledColor={lightGray}
  animationOptions={{
      animationFunction: Animated.timing,
      config: { easing: Easing.linear },
  }}
/>

@nerdmed
Copy link
Contributor Author

nerdmed commented Aug 4, 2017

@oblador Any feedback?

@kesha-antonov
Copy link

Would love to try this 👍

@oblador
Copy link
Owner

oblador commented Aug 14, 2017

Looks good @nerdmed, just need to find some time to properly review and test it again. Thanks for your patience!

@oblador
Copy link
Owner

oblador commented Aug 22, 2017

Looks great! I'm going to merge this and make some change to the props API myself. Thanks again!

@oblador oblador merged commit 3d7b488 into oblador:master Aug 22, 2017
@oblador
Copy link
Owner

oblador commented Aug 22, 2017

Released in 3.4.0.

@MrHubble
Copy link

MrHubble commented Sep 26, 2017

@nerdmed @oblador thanks so much for adding this functionality. When I use useNativeDriver my progressBar indicator is no longer displayed correctly. It goes from this:

screen shot 2017-09-26 at 3 10 50 pm

to this:

screen shot 2017-09-26 at 3 11 29 pm

with code:

<ProgressBar
  useNativeDriver
  indeterminate={true}
  height={50} width={300} color={"#df691a"} unfilledColor={"#4e5d6c"} borderWidth={0}
/>

Any idea what I'm doing wrong here?

Update

When I use the correct syntax of useNativeDriver={true} I see no indicator at all.

@nerdmed
Copy link
Contributor Author

nerdmed commented Sep 26, 2017

@MrHubble can you try to disable: indeterminate={true}

@MrHubble
Copy link

@nerdmed thanks for taking the time to response. I'm actually not updating the progress in this instance and am using the ProgressBar as a sort of loading spinner. Because of this disabling indeterminate means the progress indicator does not move. Do you know of anything else I could try to make both indeterminate and useNativeDriver work together?

@nerdmed
Copy link
Contributor Author

nerdmed commented Sep 29, 2017

@MrHubble I am not sure what the problem is. I was just guessing cause after reading the source code i was impressed how complicated this indeterminate stuff makes all the code. If you could provide a small react native example with your problem i could try to debug it with you.

@MrHubble
Copy link

MrHubble commented Oct 9, 2017

@nerdmed I'm really stumped with this one. I created a sample app with create-react-native-app (CRNA) and it worked fine, I then copied that code to my app (with a few minor modifications ie using AppRegistry) and it doesn't display the same (as per my screenshots above )

I've checked that versions match in package.json, I've tried deleting and moving around lots of parts of the code but like I mentioned it's essentially the same working code I copied across from my CRNA app.

The only thing I can think to try is to manually set the innerWidth but I can't quite figure out how to do this from the code. Are you aware if this is possible?

screen shot 2017-10-09 at 12 37 11 pm

https://github.com/oblador/react-native-progress/blob/e26623be7229acbb3526327199fb6812d57dfee3/Bar.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants