Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Animation Stutter in Production Environment] Slider value should be changed via setState or not? #101

Open
themakerman opened this issue Jan 25, 2018 · 0 comments

Comments

@themakerman
Copy link

themakerman commented Jan 25, 2018

Hi Guys,

I am developing a music player where i am trying to make the performance of animation and slider more fluid. I was using slider provided by vanilla react native and implemented the setState logic. The result was ok but as soon as i start panResponder gesture processing, the animation looses its smoothness.

I saw this library where @jeanregisser said instead of setState, Animated is being used which is an ideal scenario as it won't cause unnecessary re-rendering. But even after using this library i face the same lag.

This is the result i get in production environment.
https://drive.google.com/open?id=1Q_QbUWpLTF9QsO1h8zyXzN_mlVVNzRhf

state = { currentStateBasedTime: 0, isPlaying: true, isLiked: true, onRepeat: true, songChanged: false };
.
.
.

> fetchCurrentTrackTime() {
>       this.audioFile.getCurrentTime((seconds, isPlaying) => {
>         if (isPlaying) {
>           this.setState({ currentStateBasedTime: seconds });
>         }
>       }
>     );
>     return this.state.currentStateBasedTime;
>   }
> .
> .
> .
> somewhere inside render() {
>  <Slider
>                 maximumValue={this.getTrackLength()}
>                 maximumTrackTintColor='#971C1C'
>                 minimumTrackTintColor='#FF5252'
>                 thumbTintColor='#971C1C'
>                 style={styles.sliderStyle}
>                 value={this.fetchCurrentTrackTime()}
>    />
> }
> fetchCurrentTrackTime() {
>       this.audioFile.getCurrentTime((seconds, isPlaying) => {
>         if (isPlaying) {
>           this.setState({ currentStateBasedTime: seconds });
>         }
>       }
>     );
>     return this.state.currentStateBasedTime;
>   }
> .
> .
> .
> somewhere inside render() {
>  <Slider
>                 maximumValue={this.getTrackLength()}
>                 maximumTrackTintColor='#971C1C'
>                 minimumTrackTintColor='#FF5252'
>                 thumbTintColor='#971C1C'
>                 style={styles.sliderStyle}
>                 value={this.fetchCurrentTrackTime()}
>    />
> }
@themakerman themakerman changed the title value should be changed via setState or not? [Animation Stutter in Production Environment] Slider value should be changed via setState or not? Jan 25, 2018
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

No branches or pull requests

1 participant