Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
Fix: focusing large items already in view causes scrolling
Browse files Browse the repository at this point in the history
Closes #69
  • Loading branch information
nbilyk committed Oct 21, 2018
1 parent 7ecb2df commit 6b4c6c4
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions AcornUiCore/src/com/acornui/component/scroll/ScrollArea.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,20 @@ fun ScrollArea.scrollTo(bounds: RectangleRo) {
*/
fun ScrollArea.scrollTo(bounds: MinMaxRo) {
validate(ValidationFlags.LAYOUT)
if (bounds.xMin < hScrollModel.value)
hScrollModel.value = bounds.xMin
if (bounds.yMin < vScrollModel.value)
vScrollModel.value = bounds.yMin
val contentsSetW = contentsWidth - hScrollModel.max
if (bounds.xMax > hScrollModel.value + contentsSetW)
hScrollModel.value = bounds.xMax - contentsSetW
val contentsSetH = contentsHeight - vScrollModel.max
if (bounds.yMax > vScrollModel.value + contentsSetH)
vScrollModel.value = bounds.yMax - contentsSetH
if (bounds.xMin >= hScrollModel.value || bounds.xMax <= hScrollModel.value + contentsSetW) {
if (bounds.xMin < hScrollModel.value)
hScrollModel.value = bounds.xMin
if (bounds.xMax > hScrollModel.value + contentsSetW)
hScrollModel.value = bounds.xMax - contentsSetW
}
if (bounds.yMin >= vScrollModel.value || bounds.yMax <= vScrollModel.value + contentsSetH) {
if (bounds.yMin < vScrollModel.value)
vScrollModel.value = bounds.yMin
if (bounds.yMax > vScrollModel.value + contentsSetH)
vScrollModel.value = bounds.yMax - contentsSetH
}
}

fun ScrollArea.tweenScrollX(duration: Float, ease: Interpolation, toScrollX: Float, delay: Float = 0f): Tween {
Expand Down

0 comments on commit 6b4c6c4

Please sign in to comment.