Skip to content

Commit

Permalink
Do not render edge effects when View.OVER_SCROLL_NEVER has been speci…
Browse files Browse the repository at this point in the history
…fied while dragging (issue h6ah4i#374)
  • Loading branch information
h6ah4i committed Mar 25, 2017
1 parent 096a9b5 commit 33656ed
Showing 1 changed file with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1372,36 +1372,37 @@ private void handleScrollOnDraggingInternalWithRecyclerView(RecyclerView rv, boo
decorator.setIsScrolling(false);
}

final boolean actualIsScrolling = (actualScrolledAmount != 0);


if (mEdgeEffectDecorator != null) {
final float edgeEffectStrength = 0.005f;

final int draggingItemTopLeft = (horizontal) ? decorator.getTranslatedItemPositionLeft() : decorator.getTranslatedItemPositionTop();
final int draggingItemBottomRight = (horizontal) ? decorator.getTranslatedItemPositionRight() : decorator.getTranslatedItemPositionBottom();
final int draggingItemCenter = (draggingItemTopLeft + draggingItemBottomRight) / 2;
final int nearEdgePosition;
float edgeEffectPullDistance = 0;

if (firstVisibleChild == 0 && lastVisibleChild == 0) {
// has only 1 item
nearEdgePosition = (scrollAmount < 0) ? draggingItemTopLeft : draggingItemBottomRight;
} else {
nearEdgePosition = (draggingItemCenter < (edge / 2)) ? draggingItemTopLeft : draggingItemBottomRight;
}
if (mOrigOverScrollMode != View.OVER_SCROLL_NEVER) {
final boolean actualIsScrolling = (actualScrolledAmount != 0);
final float edgeEffectStrength = 0.005f;

final float nearEdgeOffset = (nearEdgePosition * invEdge) - 0.5f;
final float absNearEdgeOffset = Math.abs(nearEdgeOffset);
float edgeEffectPullDistance = 0;
final int draggingItemTopLeft = (horizontal) ? decorator.getTranslatedItemPositionLeft() : decorator.getTranslatedItemPositionTop();
final int draggingItemBottomRight = (horizontal) ? decorator.getTranslatedItemPositionRight() : decorator.getTranslatedItemPositionBottom();
final int draggingItemCenter = (draggingItemTopLeft + draggingItemBottomRight) / 2;
final int nearEdgePosition;

if ((absNearEdgeOffset > 0.4f) && (scrollAmount != 0) && !actualIsScrolling) {
if (nearEdgeOffset < 0) {
if (horizontal ? decorator.isReachedToLeftLimit() : decorator.isReachedToTopLimit()) {
edgeEffectPullDistance = -mDisplayDensity * edgeEffectStrength;
}
if (firstVisibleChild == 0 && lastVisibleChild == 0) {
// has only 1 item
nearEdgePosition = (scrollAmount < 0) ? draggingItemTopLeft : draggingItemBottomRight;
} else {
if (horizontal ? decorator.isReachedToRightLimit() : decorator.isReachedToBottomLimit()) {
edgeEffectPullDistance = mDisplayDensity * edgeEffectStrength;
nearEdgePosition = (draggingItemCenter < (edge / 2)) ? draggingItemTopLeft : draggingItemBottomRight;
}

final float nearEdgeOffset = (nearEdgePosition * invEdge) - 0.5f;
final float absNearEdgeOffset = Math.abs(nearEdgeOffset);

if ((absNearEdgeOffset > 0.4f) && (scrollAmount != 0) && !actualIsScrolling) {
if (nearEdgeOffset < 0) {
if (horizontal ? decorator.isReachedToLeftLimit() : decorator.isReachedToTopLimit()) {
edgeEffectPullDistance = -mDisplayDensity * edgeEffectStrength;
}
} else {
if (horizontal ? decorator.isReachedToRightLimit() : decorator.isReachedToBottomLimit()) {
edgeEffectPullDistance = mDisplayDensity * edgeEffectStrength;
}
}
}
}
Expand Down

0 comments on commit 33656ed

Please sign in to comment.