Skip to content

Instantly share code, notes, and snippets.

@eddieberklee
Created April 25, 2016 23:11
Show Gist options
  • Save eddieberklee/0587f8add6523e57775c3fe04b998514 to your computer and use it in GitHub Desktop.
Save eddieberklee/0587f8add6523e57775c3fe04b998514 to your computer and use it in GitHub Desktop.
Code for opening/closing based on a threshold of how far the container was dragged
boolean shouldClose;
float translationY = mEventsSliderContainer.getTranslationY();
if (isOpen) {
shouldClose = (translationY > mScrollViewHeight / 2)
|| (translationY > OPEN_CLOSE_THRESHOLD);
} else { // already closed, when should it remain closed
shouldClose = (translationY > mScrollViewHeight / 2)
&& (translationY > mScrollViewHeight - OPEN_CLOSE_THRESHOLD);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment