Skip to content

Commit fc6be02

Browse files
committed
Fix #4
1 parent 1637ddc commit fc6be02

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

circularlayoutmanagerlib/src/main/java/com/leshchenko/circularlayoutmanagerlib/CircularRecyclerLayoutManager.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ class CircularRecyclerLayoutManager(
5050

5151
val circleRadius = firstCircleRadius + (itemWidth * 1.5 * circleOrderPosition)
5252

53-
val angleStep =
54-
if (angleStepForCircles.isNaN()) anglePerItem.div(2) else angleStepForCircles
53+
val angleStep = if (angleStepForCircles.isNaN()) anglePerItem.div(2) else angleStepForCircles
5554

5655
val direction = if (isClockwise) -1 else 1
57-
val angle = (anglePerItem * position * direction) + if (circleOrderPosition.isDivideByTwo()) initialAngle else angleStep
56+
val maxAngle = anglePerItem * itemsPerCircle
57+
val angleCalculation = (anglePerItem * position * direction) % maxAngle
58+
val angleOffset = if (circleOrderPosition.isDivideByTwo()) angleStep else 0.0
59+
val angle = (angleCalculation + angleOffset + initialAngle)
5860

5961
val positionData = calculatePosition(circleRadius, angle)
6062

0 commit comments

Comments
 (0)