File tree 1 file changed +9
-1
lines changed
lib/java/com/google/android/material/carousel
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 34
34
*/
35
35
public class CarouselSnapHelper extends SnapHelper {
36
36
37
+ private static final float HORIZONTAL_SNAP_SPEED = 100F ;
38
+
39
+ private static final float VERTICAL_SNAP_SPEED = 50F ;
40
+
37
41
private final boolean disableFling ;
38
42
private RecyclerView recyclerView ;
39
43
@@ -245,7 +249,11 @@ protected void onTargetFound(
245
249
246
250
@ Override
247
251
protected float calculateSpeedPerPixel (DisplayMetrics displayMetrics ) {
248
- return 100.0F / (float ) displayMetrics .densityDpi ;
252
+ // If the carousel orientation is vertical, we want the scroll speed to be faster.
253
+ if (layoutManager .canScrollVertically ()) {
254
+ return VERTICAL_SNAP_SPEED / (float ) displayMetrics .densityDpi ;
255
+ }
256
+ return HORIZONTAL_SNAP_SPEED / (float ) displayMetrics .densityDpi ;
249
257
}
250
258
}
251
259
: null ;
You can’t perform that action at this time.
0 commit comments