browniefed / react-native-animation-book

A book talking about react-native animations, and walking you through from beginner to expert.
https://animationbook.codedaily.io
MIT License
643 stars 52 forks source link

Fixing some typo's + corrected a statement #13

Closed ixje closed 7 years ago

ixje commented 7 years ago

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.

browniefed commented 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.

ixje commented 7 years ago

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.

browniefed commented 7 years ago

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
})
ixje commented 7 years ago

ah I see, you were referring to the output value. I get it now. I restored the statement.

ixje commented 7 years ago

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.

browniefed commented 7 years ago

Thanks, been busy writing an animation course. Appreciate the cleanup