Skip to content
This repository was archived by the owner on Jul 11, 2024. It is now read-only.

Commit 162b7d4

Browse files
committed
Handle padding in end-of-carousel scroll limit
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.
1 parent eb9984b commit 162b7d4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

viewflow/src/org/taptwo/android/widget/ViewFlow.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,8 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
296296
} else if (deltaX > 0) {
297297
final int availableToScroll = getChildAt(
298298
getChildCount() - 1).getRight()
299-
- scrollX - getChildWidth();
299+
- getPaddingRight() - getHorizontalFadingEdgeLength()
300+
- scrollX - getWidth();
300301
if (availableToScroll > 0) {
301302
scrollBy(Math.min(availableToScroll, deltaX), 0);
302303
}
@@ -394,6 +395,7 @@ public boolean onTouchEvent(MotionEvent ev) {
394395
} else if (deltaX > 0) {
395396
final int availableToScroll = getChildAt(
396397
getChildCount() - 1).getRight()
398+
- getPaddingRight() - getHorizontalFadingEdgeLength()
397399
- scrollX - getChildWidth();
398400
if (availableToScroll > 0) {
399401
scrollBy(Math.min(availableToScroll, deltaX), 0);

0 commit comments

Comments
 (0)