-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add interpolate function from kmagiera with example. [WIP] #11
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
Conversation
Example/.gitignore
Outdated
| # Bundle artifact | ||
| *.jsbundle | ||
|
|
||
| # metro-with-symlinks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (metro-with-symlinks) makes developing while experimenting with the examples a lot easier. With this you can use yarn link.
b723ca3 to
b0cc908
Compare
b0cc908 to
f4ab3f8
Compare
kmagiera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for working on this. I realise its a WIP but noticed one thing about your code and wanted to let you know
src/derived.js
Outdated
|
|
||
| if (left === Extrapolate.EXTEND) { | ||
| } else if (left === Extrapolate.CLAMP) { | ||
| output = max(outputRange[0], output); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not entirely sure but this seems to be only correct if outputRange was sorted from min to max which is not a requirement. We only expect inputRange to be sorted that way.
I think it would be better to do something along these lines both for CLAMP and IDENTITY:
if (left === Extrapolate.EXTEND) {
} else if (left === Extrapolate.CLAMP) {
output = cond(lessThan(value, inputRange[0]), outputRange[0], output);
} else if (left === Extrapolate.IDENTITY) {
output = cond(lessThan(value, inputRange[0]), value, output);
}similarly for "right"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I'll change it 👍
|
Also @DylanVann I see you have a TODO list here but I think it would make it a bit easier if we could merge parts of this PR before you are done. As this PR only adds new functionality and does not change any existing behavior I suggest that we do as follows:
|
|
@kmagiera I'll remove the metro stuff for another PR and update this to be interpolate + the examples. What do you have in mind for input validation? Since the nodes are animated I don't know how we can validate that they're monotonically increasing for |
| "start": "node node_modules/react-native/local-cli/cli.js start", | ||
| "start": "metro-with-symlinks start", | ||
| "test": "jest", | ||
| "postinstall": "rm -rf node_modules/react-native-reanimated/{.git,node_modules,Example}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used this with yarn link and it deleted my git repo 😢 , but we can discuss on another PR.
|
Done. Yeah I'd also be happy with merging and doing more cleanup/refactoring of the examples in other PRs. |
kmagiera
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I couldn't get back to it sooner.
This looks great! Will merge it right away. Just wanted to check with you if you maybe have time to send follow-up PRs with the things we discussed earlier.
|
As for input validation I agree that it may not be possible to validate if animated values are passed. But I believe that more common usecase is to just pass numbers there in which case we could validate. Also regardless on that we can verify that input and output range tables have at least 2 elements and both are of the same length. |
|
@kmagiera I'll do a PR for:
Would you be opposed to using |
* Add example app setup files * Add some utility components and example screen placeholders * Add missing type export * Add one of previous examples as a playground example
* Add example app setup files * Add some utility components and example screen placeholders * Add missing type export * Add one of previous examples as a playground example
Interpolate function from #10 (comment) with extrapolation handling, examples, and documentation.
Closes #10 .