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

Animated.Value.stopAnimation(callback) always returns 0 as the callback value if useNativeDriver = true in Animated.timing #11328

Closed
cailenmusselman opened this issue Dec 6, 2016 · 3 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@cailenmusselman
Copy link
Contributor

Description

With useNativeDriver: true in Animated.timing options, Animated.Value.stopAnimation((value) => void) receives 0 as a value, regardless of the animation's progress.

Reproduction

import React from 'react';

import {
  View,
  Animated
} from 'react-native';

class App extends React.Component {
  constructor(props) {
    super(props);
  	this.state = { 
    	translateY: new Animated.Value(0) 
    };
  }
  componentDidMount() { 
    Animated.timing(this.state.translateY, { 
      useNativeDriver: true, // <- with 'false' the correct value is returned in the callback
      delay: 0,
      duration: 5000,
      toValue: 1000
    }).start();
    setTimeout(() => { 
    	this.state.translateY.stopAnimation((value) => console.warn(value)); // 'value' always 0
    }, 2000);
  }
  render() {
    return (
      <View style={{
      	height: 20,
      	width: 20,
      	backgroundColor: 'red',
      	transform: [{
          translateY: this.state.translateY
      	}]
      }}>
      </View>
    );
  }
}

Solution

value should be the animation's current value when stopped, like it is with useNativeDriver: false. Or if this isn't possible with useNativeDriver the docs should be updated.

Additional Information

  • React Native version: 0.39
  • Platform: Android (maybe both)
  • Operating System: Windows
@hramos
Copy link
Contributor

hramos commented May 25, 2017

We're cutting down on the number of outstanding issues, in order to allow us to focus. I'm closing this issue because it has been open for over 60 days with no activity. If you think it should still be opened let us know why. PRs are always welcome.

@hramos hramos closed this as completed May 25, 2017
@hramos hramos added the Icebox label May 26, 2017
@renso3x
Copy link

renso3x commented Nov 15, 2017

how does the solution look like?

@mkraessig
Copy link

This is still a problem 👋 (all platforms, 0.55.2)

@facebook facebook locked as resolved and limited conversation to collaborators Jul 19, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants