Skip to content

Commit 9f35284

Browse files
authored
Merge pull request #33 from profourone/fix/nan-animated-rotation-x
Fix NaN animated rotation x
2 parents 66305bd + 3b4108b commit 9f35284

File tree

1 file changed

+6
-1
lines changed
  • wheel-picker-compose/src/main/java/com/commandiron/wheel_picker_compose/core

1 file changed

+6
-1
lines changed

wheel-picker-compose/src/main/java/com/commandiron/wheel_picker_compose/core/WheelPicker.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,13 @@ private fun calculateAnimatedRotationX(
143143
val layoutInfo = remember { derivedStateOf { lazyListState.layoutInfo } }.value
144144
val viewPortHeight = layoutInfo.viewportSize.height.toFloat()
145145
val singleViewPortHeight = viewPortHeight / rowCount
146+
val animatedRotationX = -20f * (distanceToIndexSnap / singleViewPortHeight)
146147

147-
return -20f * (distanceToIndexSnap / singleViewPortHeight)
148+
return if (animatedRotationX.isNaN()) {
149+
0f
150+
} else {
151+
animatedRotationX
152+
}
148153
}
149154

150155
object WheelPickerDefaults{

0 commit comments

Comments
 (0)