FairyGUI.GSlider.__gripTouchMove C# (CSharp) Method

__gripTouchMove() private method

private __gripTouchMove ( EventContext context ) : void
context EventContext
return void
        private void __gripTouchMove(EventContext context)
        {
            InputEvent evt = context.inputEvent;
            if (_touchId != evt.touchId)
                return;

            Vector2 pt = this.GlobalToLocal(new Vector2(evt.x, evt.y));
            if (float.IsNaN(pt.x))
                return;

            float deltaX = pt.x - _clickPos.x;
            float deltaY = pt.y - _clickPos.y;

            float percent;
            if (_barObjectH != null)
                percent = _clickPercent + deltaX / _barMaxWidth;
            else
                percent = _clickPercent + deltaY / _barMaxHeight;
            if (percent > 1)
                percent = 1;
            else if (percent < 0)
                percent = 0;

            float newValue = percent * _max;
            if (newValue != _value)
            {
                _value = newValue;
                onChanged.Call();
            }
            UpdateWidthPercent(percent);
        }