Skip to content

Commit d568c0b

Browse files
authored
Fix PillarboxSlider min/max values (#671)
1 parent 07dddfc commit d568c0b

File tree

1 file changed

+8
-2
lines changed
  • pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components

1 file changed

+8
-2
lines changed

pillarbox-demo-shared/src/main/java/ch/srgssr/pillarbox/demo/shared/ui/components/PillarboxSlider.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,12 +331,18 @@ private fun Modifier.dragThumb(
331331
}
332332

333333
return this then Modifier.pointerInput(Unit) {
334+
fun notifySliderValueChange(offset: Offset) {
335+
val offsetX = offset.x.coerceIn(0f, size.width.toFloat())
336+
337+
onSliderValueChange(offsetX / size.width)
338+
}
339+
334340
detectHorizontalDragGestures(
335341
onDragStart = { offset ->
336342
startInteraction = DragInteraction.Start()
337343
.also { interactionSource.tryEmit(it) }
338344

339-
onSliderValueChange(offset.x / size.width)
345+
notifySliderValueChange(offset)
340346
},
341347
onDragEnd = {
342348
destroyStartInteraction(DragInteraction::Stop)
@@ -345,7 +351,7 @@ private fun Modifier.dragThumb(
345351
destroyStartInteraction(DragInteraction::Cancel)
346352
},
347353
onHorizontalDrag = { change, _ ->
348-
onSliderValueChange(change.position.x / size.width)
354+
notifySliderValueChange(change.position)
349355
},
350356
)
351357
}

0 commit comments

Comments
 (0)