forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
87c5a25
commit 920b75c
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters