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

OnPreviewTouchDrag() protected method

protected OnPreviewTouchDrag ( TouchEventArgs e ) : void
e TouchEventArgs
return void
        protected override void OnPreviewTouchDrag(TouchEventArgs e)
        {
            base.OnTouchDrag(e);

            if (e.Pointer != _draggingPointer)
                return;

            Vector2 position = e.GetPosition(this);

            if (_touchScrollH) {
                float delta = position.X - _lastPoint.X;
                float scrollH = _handlePosition + delta;
                _handlePosition = scrollH;

                scrollH = Math.Max(_hScrollBounds.X, scrollH);
                scrollH = Math.Min(_hScrollBounds.X + _hScrollBounds.Width - _hKnobBounds.Width, scrollH);

                float total = _hScrollBounds.Width - _hKnobBounds.Width;
                if (total != 0)
                    ScrollPercentX = (scrollH - _hScrollBounds.X) / total;

                _lastPoint = position;
            }
            else if (_touchScrollV) {
                float delta = position.Y - _lastPoint.Y;
                float scrollV = _handlePosition + delta;
                _handlePosition = scrollV;

                scrollV = Math.Max(_vScrollBounds.Y, scrollV);
                scrollV = Math.Min(_vScrollBounds.Y + _vScrollBounds.Height - _vKnobBounds.Height, scrollV);

                float total = _vScrollBounds.Height - _vKnobBounds.Height;
                if (total != 0)
                    ScrollPercentY = 1 - (scrollV - _vScrollBounds.Y) / total;

                _lastPoint = position;
            }
        }