Skip to content

Commit

Permalink
ScrollBarGripMinHeightConstraint: Don't create intermediate constraints
Browse files Browse the repository at this point in the history
We can work directly with the values instead of creating a bunch
of constraints which are only evaluated once before getting dropped.
  • Loading branch information
caoimhebyrne committed Jul 15, 2024
1 parent 4749845 commit 79a4357
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,10 @@ class ScrollComponent constructor(

override fun getHeightImpl(component: UIComponent): Float {
val parent = component.parent
val minimumHeight = if (parent.getHeight() < 200) { 15.percent } else { 10.percent }
return desiredHeight.coerceAtLeast(minimumHeight).getHeight(component)
val minimumHeightPercentage = if (parent.getHeight() < 200) { 0.15f } else { 0.10f }
val minimumHeight = parent.getHeight() * minimumHeightPercentage

return desiredHeight.getHeight(component).coerceAtLeast(minimumHeight)
}

override fun visitImpl(visitor: ConstraintVisitor, type: ConstraintType) {
Expand Down

0 comments on commit 79a4357

Please sign in to comment.