@@ -215,23 +215,44 @@ private void updateAlpha() {
215
215
float percentX = getPercentX ();
216
216
float percentY = getPercentY ();
217
217
218
- if (Math .abs (percentX ) > Math .abs (percentY )){
219
- if (percentX < 0 ) {
220
- showLeftOverlay ();
218
+ if (option .swipeDirection == SwipeDirection .HORIZONTAL ) {
219
+ showHorizontalOverlay (percentX );
220
+ } else if (option .swipeDirection == SwipeDirection .VERTICAL ) {
221
+ showVerticalOverlay (percentY );
222
+ } else if (option .swipeDirection == SwipeDirection .FREEDOM_NO_BOTTOM ) {
223
+ if (Math .abs (percentX ) < Math .abs (percentY ) && percentY < 0 ) {
224
+ showTopOverlay ();
225
+ setOverlayAlpha (Math .abs (percentY ));
221
226
} else {
222
- showRightOverlay ( );
227
+ showHorizontalOverlay ( percentX );
223
228
}
224
- setOverlayAlpha (Math .abs (percentX ));
225
- }else {
226
- if (percentY < 0 ) {
227
- showTopOverlay ();
229
+ } else if (option .swipeDirection == SwipeDirection .FREEDOM ) {
230
+ if (Math .abs (percentX ) > Math .abs (percentY )) {
231
+ showHorizontalOverlay (percentX );
228
232
} else {
229
- showBottomOverlay ( );
233
+ showVerticalOverlay ( percentY );
230
234
}
231
- setOverlayAlpha (Math .abs (percentY ));
232
235
}
233
236
}
234
237
238
+ private void showHorizontalOverlay (float percentX ) {
239
+ if (percentX < 0 ) {
240
+ showLeftOverlay ();
241
+ } else {
242
+ showRightOverlay ();
243
+ }
244
+ setOverlayAlpha (Math .abs (percentX ));
245
+ }
246
+
247
+ private void showVerticalOverlay (float percentY ) {
248
+ if (percentY < 0 ) {
249
+ showTopOverlay ();
250
+ } else {
251
+ showBottomOverlay ();
252
+ }
253
+ setOverlayAlpha (Math .abs (percentY ));
254
+ }
255
+
235
256
private void moveToOrigin () {
236
257
animate ().translationX (viewOriginX )
237
258
.translationY (viewOriginY )
0 commit comments