Closed ixje closed 7 years ago
I looked and I still do not believe you can add a listener to interpolated values. I know in the Animated library as an NPM module you can ( since I wrote it) but I'm not certain it's been added to the React Native version yet.
I just now created a new sample app (react-native init test
) with the following body
https://gist.github.com/ixje/4d88421366e4e5e6f907ed228d12d1ea#file-index-ios-js-L13-L37
Eriks-Air:test erik$ npm ls | grep -i animated
Eriks-Air:test erik$ npm ls | grep -i react-native
├─┬ babel-preset-react-native@2.0.0
├─┬ react-native@0.45.1
│ ├── babel-preset-react-native@1.9.2
To my best knowledge this doesn't use "Animated" as NPM module, but it does print the values in the console. As such I would think that the statement is no longer valid.
You can do an addListener
for any animated value that even uses inteprolate. What I was talking about was
animatedWidth = animatedValue.interpolate({
inputRange: [0, 1],
outputRange: [0, 10]
})
animatedWidth.addListener(({ value } ) => {
//value is in the 0 to 10 range
})
ah I see, you were referring to the output value. I get it now. I restored the statement.
Do you expect any further actions from me or? There are some 'unnecessar'y space removals as a result of using the GitBook application. The other edits are the minor typo edits that should be valid imo.
Thanks, been busy writing an animation course. Appreciate the cleanup
At the time written you stated that it is not possible to attach a listener to interpolated values. This now does work so I removed the statement/note.