internal void OnMouseWheel(Control sender, Messages.MouseWheel args) { if (!CanScroll) { return; } var direction = args.Direction == Messages.MouseWheel.Directions.Down ? 1 : -1; var step = args.ScrollSteps * ScrollStep; // Don't tween if the new position is the same as the previous position var tweenTo = -Math.Min(MaxViewIndex, Math.Max(0, -CurrentViewIndex + direction * step)); if (tweenTo == CurrentViewIndex) { return; } if (CurrentTween != null) { CurrentTween.Cancel(); } CurrentTween = Tweener.Tween(this, new { CurrentViewIndex = -Math.Min(MaxViewIndex, Math.Max(0, -CurrentViewIndex + direction * step)) }, 0.5f); CurrentTween.Ease(Ease.CircOut); CurrentTween.OnBegin(delegate { Tweening = true; }); CurrentTween.OnComplete(delegate { Tweening = false; }); }
internal bool CheckScrollbarDown(Vector2 mousePosition) { // Check if mouse is on scrollbar if (IsScrollbarNeeded && ScrollbarArea.Contains(Game.CursorPos2D)) { // Calculate new move offset MoveOffset = (int)(ScrollbarIndex - mousePosition.Y); // Allow the scrollbar to move IsScrollbarMoving = true; // Cancel current tween if (CurrentTween != null) { CurrentTween.Cancel(); Tweening = false; } return(true); } return(false); }