MonoGdx.Scene2D.UI.ScrollPane.ScrollToCenter C# (CSharp) Method

ScrollToCenter() public method

public ScrollToCenter ( float x, float y, float width, float height ) : void
x float
y float
width float
height float
return void
        public void ScrollToCenter(float x, float y, float width, float height)
        {
            float amountX = ScrollX;
            if (x + width > amountX + _areaWidth)
                amountX = x + width - _areaWidth;
            if (x < amountX)
                amountX = x;
            ScrollX = MathHelper.Clamp(amountX, 0, MaxX);

            float amountY = ScrollY;
            float centerY = MaxY - y + _areaHeight / 2 - height / 2;
            if (amountY < centerY - _areaHeight / 4 || amountY > centerY + _areaHeight / 4)
                amountY = centerY;
            ScrollY = MathHelper.Clamp(amountY, 0, MaxY);
        }