am 564a2e71: Fix custom content state for scroll in RTL (issue 11068877)
* commit '564a2e7116b026c1d73829e65d47b660b03a3c72': Fix custom content state for scroll in RTL (issue 11068877)
This commit is contained in:
@@ -1528,6 +1528,19 @@ public abstract class PagedView extends ViewGroup implements ViewGroup.OnHierarc
|
||||
}
|
||||
}
|
||||
|
||||
// While layout transitions are occurring, a child's position may stray from its baseline
|
||||
// position. This method returns the magnitude of this stray at any given time.
|
||||
public int getLayoutTransitionOffsetForPage(int index) {
|
||||
if (mPageScrolls == null || index >= mPageScrolls.length || index < 0) {
|
||||
return 0;
|
||||
} else {
|
||||
View child = getChildAt(index);
|
||||
int scrollOffset = (getViewportWidth() - child.getMeasuredWidth()) / 2;
|
||||
int baselineX = mPageScrolls[index] + scrollOffset + getViewportOffsetX();
|
||||
return (int) (child.getX() - baselineX);
|
||||
}
|
||||
}
|
||||
|
||||
// This curve determines how the effect of scrolling over the limits of the page dimishes
|
||||
// as the user pulls further and further from the bounds
|
||||
private float overScrollInfluenceCurve(float f) {
|
||||
|
||||
@@ -1387,7 +1387,9 @@ public class Workspace extends SmoothPagedView
|
||||
float progress = 0;
|
||||
if (hasCustomContent()) {
|
||||
int index = mScreenOrder.indexOf(CUSTOM_CONTENT_SCREEN_ID);
|
||||
int scrollDelta = getScrollForPage(index + 1) - getScrollX();
|
||||
|
||||
int scrollDelta = getScrollForPage(index + 1) - getScrollX() +
|
||||
getLayoutTransitionOffsetForPage(index + 1);
|
||||
translationX = scrollDelta;
|
||||
progress = (1.0f * scrollDelta) /
|
||||
(getScrollForPage(index + 1) - getScrollForPage(index));
|
||||
|
||||
Reference in New Issue
Block a user