Skip to content

Commit

Permalink
Handle padding in end-of-carousel scroll limit
Browse files Browse the repository at this point in the history
My recent change to support padding also necessitates a change to the
touch handlers, when they work out whether we can scroll any further.
It's now necessary to compare the child's right edge with the inner
boundary, not the outer width.
  • Loading branch information
orac committed Jul 16, 2013
1 parent eb9984b commit 162b7d4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion viewflow/src/org/taptwo/android/widget/ViewFlow.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
} else if (deltaX > 0) {
final int availableToScroll = getChildAt(
getChildCount() - 1).getRight()
- scrollX - getChildWidth();
- getPaddingRight() - getHorizontalFadingEdgeLength()
- scrollX - getWidth();
if (availableToScroll > 0) {
scrollBy(Math.min(availableToScroll, deltaX), 0);
}
Expand Down Expand Up @@ -394,6 +395,7 @@ public boolean onTouchEvent(MotionEvent ev) {
} else if (deltaX > 0) {
final int availableToScroll = getChildAt(
getChildCount() - 1).getRight()
- getPaddingRight() - getHorizontalFadingEdgeLength()
- scrollX - getChildWidth();
if (availableToScroll > 0) {
scrollBy(Math.min(availableToScroll, deltaX), 0);
Expand Down

0 comments on commit 162b7d4

Please sign in to comment.