Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
[Animated] Add AnimatedDiffClamp node #9419
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:
This gives the following output for parameters min = 0, max = 30:
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.
Created a small example of a collapsible navbar in UIExplorer, will also add unit tests before shipping if we are happy with this approach.
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
It would seem that nobody disagrees with this based off of lack of response ;P @janicduplessis - maybe just rename to
changed the title from
[Animated] Add AnimatedClamp node
[Animated] Add AnimatedDiffClamp node
Aug 21, 2016
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.