Fix wrong scrolling (#6809)
authorVitaliy <silverunicorn2011@yandex.ru>
Thu, 21 Dec 2017 19:58:06 +0000 (22:58 +0300)
committerSmallJoker <mk939@ymail.com>
Sun, 3 Jun 2018 15:32:00 +0000 (17:32 +0200)
src/intlGUIEditBox.cpp

index 37687e1e4b6e019cb529fe1b54da63538e9ee0e5..ad59ef13a2b9fd04f5c86cf354495a722151af2a 100644 (file)
@@ -1419,13 +1419,10 @@ void intlGUIEditBox::calculateScrollPos()
        }
 
        // vertical scroll position
-       if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y + VScrollPos)
-               VScrollPos = CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y + VScrollPos;
-
-       else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y + VScrollPos)
-               VScrollPos = CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y + VScrollPos;
-       else
-               VScrollPos = 0;
+       if (FrameRect.LowerRightCorner.Y < CurrentTextRect.LowerRightCorner.Y)
+               VScrollPos += CurrentTextRect.LowerRightCorner.Y - FrameRect.LowerRightCorner.Y; // scrolling downwards
+       else if (FrameRect.UpperLeftCorner.Y > CurrentTextRect.UpperLeftCorner.Y)
+               VScrollPos += CurrentTextRect.UpperLeftCorner.Y - FrameRect.UpperLeftCorner.Y; // scrolling upwards
 
        // todo: adjust scrollbar
 }