Fix wrong scrolling (#6809)
authorVitaliy <silverunicorn2011@yandex.ru>
Thu, 21 Dec 2017 19:58:06 +0000 (22:58 +0300)
committerSmallJoker <SmallJoker@users.noreply.github.com>
Thu, 21 Dec 2017 19:58:06 +0000 (20:58 +0100)
src/gui/intlGUIEditBox.cpp

index c03256ede0b8204cf12b2add4690d9ffd20e9dca..f5ea5b47fe1a7e86ff2d30aab1dc5979f63cb366 100644 (file)
@@ -1431,13 +1431,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
        if (m_vscrollbar)