/// <summary> /// Handle scroll changes. /// </summary> protected override void ScrollChanged() { if (!gameObject.activeInHierarchy) { return; } var distance = Mathf.Abs(IsHorizontal() ? DragDelta.x : DragDelta.y); var time = Utilites.GetUnscaledTime() - DragStarted; var is_fast = (distance >= FastDragDistance) && (time <= FastDragTime); if (!is_fast) { var page = Mathf.FloorToInt(((float)ListView.GetNearestItemIndex()) / (ListView.GetItemsPerBlock() * PerPage)); GoToPage(page, true); DragDelta = Vector2.zero; DragStarted = 0f; } else { var direction = IsHorizontal() ? DragDelta.x : -DragDelta.y; DragDelta = Vector2.zero; if (direction == 0f) { return; } var page = direction < 0 ? CurrentPage + 1 : CurrentPage - 1; GoToPage(page, false); } }