material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[SwipeDismissBehavior]Fixed drag view alpha not changing when swipeDirection is END_TO_START

Open kingwang666 opened this issue 3 years ago • 0 comments

Drag view alpha not changing when swipeDirection is END_TO_START.

          final float startAlphaDistance =
              originalCapturedViewLeft + child.getWidth() * alphaStartSwipeDistance;
          final float endAlphaDistance =
              originalCapturedViewLeft + child.getWidth() * alphaEndSwipeDistance;

          if (left <= startAlphaDistance) {
            child.setAlpha(1f);
          } else if (left >= endAlphaDistance) {
            child.setAlpha(0f);
          } else {
            // We're between the start and end distances
            final float distance = fraction(startAlphaDistance, endAlphaDistance, left);
            child.setAlpha(clamp(0f, 1f - distance, 1f));
          }

the left is always < startAlphaDistance

kingwang666 avatar Aug 03 '22 12:08 kingwang666