You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/AppScrollbars.kt
Copy file name to clipboardExpand all lines: core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/LazyScrollbarUtilities.kt
+4-6Lines changed: 4 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,7 @@ import kotlin.math.min
33
33
* Calculates the [ScrollbarState] for lazy layouts.
34
34
* @param itemsAvailable the total amount of items available to scroll in the layout.
35
35
* @param visibleItems a list of items currently visible in the layout.
36
-
* @param firstItemIndex a function for interpolating the first visible index in the lazy layout
36
+
* @param firstVisibleItemIndex a function for interpolating the first visible index in the lazy layout
37
37
* as scrolling progresses for smooth and linear scrollbar thumb progression.
38
38
* [itemsAvailable].
39
39
* @param reverseLayout if the items in the backing lazy layout are laid out in reverse order.
Copy file name to clipboardExpand all lines: core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/Scrollbar.kt
+65-57Lines changed: 65 additions & 57 deletions
Original file line number
Diff line number
Diff line change
@@ -57,8 +57,8 @@ import kotlinx.coroutines.delay
57
57
importkotlin.math.max
58
58
importkotlin.math.min
59
59
60
-
privateconstvalSCROLLBAR_PRESS_DELAY=100L
61
-
privateconstvalSCROLLBAR_PRESS_DELTA=0.1f
60
+
privateconstvalSCROLLBAR_PRESS_DELAY=10L
61
+
privateconstvalSCROLLBAR_PRESS_DELTA=0.02f
62
62
63
63
/**
64
64
* Class definition for the core properties of a scroll bar
@@ -71,7 +71,7 @@ value class ScrollbarState internal constructor(
71
71
companionobject {
72
72
valFULL=ScrollbarState(
73
73
thumbSizePercent =1f,
74
-
thumbTravelPercent=0f,
74
+
thumbDisplacementPercent=0f,
75
75
)
76
76
}
77
77
}
@@ -93,15 +93,16 @@ private value class ScrollbarTrack(
93
93
/**
94
94
* Creates a scrollbar state with the listed properties
95
95
* @param thumbSizePercent the thumb size of the scrollbar as a percentage of the total track size
96
-
* @param thumbTravelPercent the distance the thumb has traveled as a percentage of total track size
96
+
* @param thumbDisplacementPercent the distance the thumb has traveled as a percentage of total
97
+
* track size
97
98
*/
98
99
funScrollbarState(
99
100
thumbSizePercent:Float,
100
-
thumbTravelPercent:Float,
101
+
thumbDisplacementPercent:Float,
101
102
) =ScrollbarState(
102
103
packFloats(
103
104
val1 = thumbSizePercent,
104
-
val2 =thumbTravelPercent,
105
+
val2 =thumbDisplacementPercent,
105
106
),
106
107
)
107
108
@@ -114,7 +115,7 @@ val ScrollbarState.thumbSizePercent
114
115
/**
115
116
* Returns the distance the thumb has traveled as a percentage of total track size
116
117
*/
117
-
valScrollbarState.thumbTravelPercent
118
+
valScrollbarState.thumbDisplacementPercent
118
119
get() = unpackFloat2(packedValue)
119
120
120
121
/**
@@ -167,8 +168,8 @@ internal fun Orientation.valueOf(intOffset: IntOffset) = when (this) {
167
168
* @param minThumbSize the minimum size of the scrollbar thumb
168
169
* @param interactionSource allows for observing the state of the scroll bar
169
170
* @param thumb a composable for drawing the scrollbar thumb
170
-
* @param onThumbMoved an function for reacting to scroll bar interactions, for example implementing
171
-
* a fast scroll
171
+
* @param onThumbDisplaced an function for reacting to scroll bar displacements caused by direct
172
+
* interactions on the scrollbar thumb by the user, for example implementing a fast scroll
Copy file name to clipboardExpand all lines: core/designsystem/src/main/java/com/google/samples/apps/nowinandroid/core/designsystem/component/scrollbar/ScrollbarExt.kt
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ fun LazyListState.scrollbarState(
37
37
scrollbarState(
38
38
itemsAvailable = itemsAvailable,
39
39
visibleItems = { layoutInfo.visibleItemsInfo },
40
-
firstItemIndex= { visibleItems ->
40
+
firstVisibleItemIndex= { visibleItems ->
41
41
interpolateFirstItemIndex(
42
42
visibleItems = visibleItems,
43
43
itemSize = { it.size },
@@ -71,7 +71,7 @@ fun LazyGridState.scrollbarState(
0 commit comments