From 988f404ebc938320aec4bed622bc1e3dcdee7070 Mon Sep 17 00:00:00 2001 From: Gualdimar Date: Wed, 15 Mar 2023 08:37:09 +0200 Subject: [PATCH] World wrap scrolling fix (#8903) --- .../unciv/ui/components/ZoomableScrollPane.kt | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/core/src/com/unciv/ui/components/ZoomableScrollPane.kt b/core/src/com/unciv/ui/components/ZoomableScrollPane.kt index 5f87263265..f2f93b0eaa 100644 --- a/core/src/com/unciv/ui/components/ZoomableScrollPane.kt +++ b/core/src/com/unciv/ui/components/ZoomableScrollPane.kt @@ -80,6 +80,17 @@ open class ZoomableScrollPane( onViewportChanged() } + override fun setScrollX(pixels: Float) { + var result = pixels + + if (continuousScrollingX) { + if (result < 0f) result += maxX + else if (result > maxX) result -= maxX + } + + super.setScrollX(result) + } + override fun scrollY(pixelsY: Float) { super.scrollY(pixelsY) updateCulling() @@ -293,15 +304,6 @@ open class ZoomableScrollPane( scrollX = restrictX(deltaX) scrollY = restrictY(deltaY) - when { - continuousScrollingX && scrollPercentX >= 1 && deltaX < 0 -> { - scrollPercentX = 0f - } - continuousScrollingX && scrollPercentX <= 0 && deltaX > 0-> { - scrollPercentX = 1f - } - } - //clamp() call is missing here but it doesn't seem to make any big difference in this case if ((isScrollX && deltaX != 0f || isScrollY && deltaY != 0f))