File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
lib/java/com/google/android/material/carousel Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 3434 */
3535public class CarouselSnapHelper extends SnapHelper {
3636
37+ private static final float HORIZONTAL_SNAP_SPEED = 100F ;
38+
39+ private static final float VERTICAL_SNAP_SPEED = 50F ;
40+
3741 private final boolean disableFling ;
3842 private RecyclerView recyclerView ;
3943
@@ -245,7 +249,11 @@ protected void onTargetFound(
245249
246250 @ Override
247251 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 ;
249257 }
250258 }
251259 : null ;
You can’t perform that action at this time.
0 commit comments