-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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] Add AnimatedDiffClamp node #9419
[Animated] Add AnimatedDiffClamp node #9419
Conversation
iirc the scrollY becomes negative during bounce, so we could maybe do something like this (would require a new node type :P):
But then we might have the same problem when we hit the bottom of the ScrollView! So we'd need to add a |
Another thought -- maybe instead of just |
Yeah we definitely need a new name I just had no inspiration :), I kind of like As for bouncing it should be fixable by using interpolate with mode clamp to the scrollY animated value. |
It would seem that nobody disagrees with this based off of lack of response ;P @janicduplessis - maybe just rename to |
@janicduplessis updated the pull request - view changes |
@brentvatne renamed + added a small test. |
@facebook-github-bot shipit |
Thanks for importing.If you are an FB employee go to Phabricator to review internal test results. |
4d21523
to
980c95c
Compare
@janicduplessis updated the pull request - view changes - changes since last import |
@brentvatne Oups there was a conflict, might need to reship. |
I tried to merge this pull request into the Facebook internal repo but some checks failed. To unblock yourself please check the following: Does this pull request pass all open source tests on GitHub? If not please fix those. Does the code still apply cleanly on top of GitHub master? If not can please rebase. In all other cases this means some internal test failed, for example a part of a fb app won't work with this pull request. I've added the Import Failed label to this pull request so it is easy for someone at fb to find the pull request and check what failed. If you don't see anyone comment in a few days feel free to comment mentioning one of the core contributors to the project so they get a notification. |
@facebook-github-bot shipit |
Thanks for importing.If you are an FB employee go to Phabricator to review internal test results. |
cd1d652
Summary: This adds a new type of node that clamps an animated value between 2 values with a special twist, it is based on the difference between the previous value so getting far from a bound doesn't matter and as soon as we start getting closer again the value will start changing. The main use case for this node is to create a collapsible navbar when scrolling a scrollview. This is a pretty in apps (fb, youtube, twitter, all use something like this). It updates using the following: `value = clamp(value + diff, min, max)` where `diff` is the difference with the previous value. This gives the following output for parameters min = 0, max = 30: ``` in out 0 0 15 15 30 30 100 30 90 20 30 0 50 20 ``` One issue I see is that this node is pretty specific to this use case but I can't see another simple way to do this with Animated that can also be offloaded to native easily. I'd be glad to discuss other solutions if some Closes facebook#9419 Differential Revision: D3753920 fbshipit-source-id: 40a749d38fd003aab2d3cb5cb8f0535e467d8a2a
Summary: Add native support on iOS and Android for `Animated.diffClamp` that was added in facebook#9419. **Test plan** Tested that it works properly using the native animations UIExplorer example. Closes facebook#9691 Differential Revision: D3813440 fbshipit-source-id: 48a3ecddf3708fa44b408954d3d8133ec8537f21
Summary: This adds a new type of node that clamps an animated value between 2 values with a special twist, it is based on the difference between the previous value so getting far from a bound doesn't matter and as soon as we start getting closer again the value will start changing. The main use case for this node is to create a collapsible navbar when scrolling a scrollview. This is a pretty in apps (fb, youtube, twitter, all use something like this). It updates using the following: `value = clamp(value + diff, min, max)` where `diff` is the difference with the previous value. This gives the following output for parameters min = 0, max = 30: ``` in out 0 0 15 15 30 30 100 30 90 20 30 0 50 20 ``` One issue I see is that this node is pretty specific to this use case but I can't see another simple way to do this with Animated that can also be offloaded to native easily. I'd be glad to discuss other solutions if some Closes facebook#9419 Differential Revision: D3753920 fbshipit-source-id: 40a749d38fd003aab2d3cb5cb8f0535e467d8a2a
Summary: Add native support on iOS and Android for `Animated.diffClamp` that was added in facebook#9419. **Test plan** Tested that it works properly using the native animations UIExplorer example. Closes facebook#9691 Differential Revision: D3813440 fbshipit-source-id: 48a3ecddf3708fa44b408954d3d8133ec8537f21
Summary: This adds a new type of node that clamps an animated value between 2 values with a special twist, it is based on the difference between the previous value so getting far from a bound doesn't matter and as soon as we start getting closer again the value will start changing. The main use case for this node is to create a collapsible navbar when scrolling a scrollview. This is a pretty in apps (fb, youtube, twitter, all use something like this). It updates using the following: `value = clamp(value + diff, min, max)` where `diff` is the difference with the previous value. This gives the following output for parameters min = 0, max = 30: ``` in out 0 0 15 15 30 30 100 30 90 20 30 0 50 20 ``` One issue I see is that this node is pretty specific to this use case but I can't see another simple way to do this with Animated that can also be offloaded to native easily. I'd be glad to discuss other solutions if some Closes facebook#9419 Differential Revision: D3753920 fbshipit-source-id: 40a749d38fd003aab2d3cb5cb8f0535e467d8a2a
Summary: Add native support on iOS and Android for `Animated.diffClamp` that was added in facebook#9419. **Test plan** Tested that it works properly using the native animations UIExplorer example. Closes facebook#9691 Differential Revision: D3813440 fbshipit-source-id: 48a3ecddf3708fa44b408954d3d8133ec8537f21
Summary: This adds a new type of node that clamps an animated value between 2 values with a special twist, it is based on the difference between the previous value so getting far from a bound doesn't matter and as soon as we start getting closer again the value will start changing. The main use case for this node is to create a collapsible navbar when scrolling a scrollview. This is a pretty in apps (fb, youtube, twitter, all use something like this). It updates using the following: `value = clamp(value + diff, min, max)` where `diff` is the difference with the previous value. This gives the following output for parameters min = 0, max = 30: ``` in out 0 0 15 15 30 30 100 30 90 20 30 0 50 20 ``` One issue I see is that this node is pretty specific to this use case but I can't see another simple way to do this with Animated that can also be offloaded to native easily. I'd be glad to discuss other solutions if some Closes facebook#9419 Differential Revision: D3753920 fbshipit-source-id: 40a749d38fd003aab2d3cb5cb8f0535e467d8a2a
Summary: Add native support on iOS and Android for `Animated.diffClamp` that was added in facebook#9419. **Test plan** Tested that it works properly using the native animations UIExplorer example. Closes facebook#9691 Differential Revision: D3813440 fbshipit-source-id: 48a3ecddf3708fa44b408954d3d8133ec8537f21
Add support for DiffClamp node on Windows for `Animated.diffClamp` that was added in facebook/react-native#9419.
Add support for DiffClamp node on Windows for `Animated.diffClamp` that was added in facebook/react-native#9419.
Add support for DiffClamp node on Windows for `Animated.diffClamp` that was added in facebook/react-native#9419.
Motivation
This adds a new type of node that clamps an animated value between 2 values with a special twist, it is based on the difference between the previous value so getting far from a bound doesn't matter and as soon as we start getting closer again the value will start changing. The main use case for this node is to create a collapsible navbar when scrolling a scrollview. This is a pretty in apps (fb, youtube, twitter, all use something like this).
It updates using the following:
value = clamp(value + diff, min, max)
wherediff
is the difference with the previous value.This gives the following output for parameters min = 0, max = 30:
Potential issues
One issue I see is that this node is pretty specific to this use case but I can't see another simple way to do this with Animated that can also be offloaded to native easily. I'd be glad to discuss other solutions if someone comes up with another idea.
Test plan
Created a small example of a collapsible navbar in UIExplorer, will also add unit tests before shipping if we are happy with this approach.
Code: https://github.com/janicduplessis/react-native/blob/test-1/Examples/UIExplorer/js/CollapsibleNavbarExample.js