Skip to content

Instantly share code, notes, and snippets.

@MrCrambo
Created July 25, 2020 08:43
Show Gist options
  • Save MrCrambo/e176d580d796e89aab35cf52b1518673 to your computer and use it in GitHub Desktop.
Save MrCrambo/e176d580d796e89aab35cf52b1518673 to your computer and use it in GitHub Desktop.
int currentTop = child.getTop();
int newTop = currentTop - dy;
if (dy > 0) {
if (!ViewCompat.canScrollVertically(target, 1)) {
if (newTop >= mMinOffset || mHideable) {
consumed[1] = dy;
ViewCompat.offsetTopAndBottom(child, -dy);
setStateInternal(STATE_DRAGGING);
} else {
consumed[1] = currentTop - mMinOffset;
ViewCompat.offsetTopAndBottom(child, -consumed[1]);
setStateInternal(STATE_COLLAPSED);
}
}
} else if (dy < 0) {
if (newTop < mMaxOffset) {
consumed[1] = dy;
ViewCompat.offsetTopAndBottom(child, -dy);
setStateInternal(STATE_DRAGGING);
} else {
consumed[1] = currentTop - mMaxOffset;
ViewCompat.offsetTopAndBottom(child, -consumed[1]);
setStateInternal(STATE_EXPANDED);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment