/// <summary> /// Scrolls to item with specifid index. /// </summary> /// <param name="index">Index.</param> protected override void ScrollTo(int index) { if (!CanOptimize()) { return; } var first_visible = GetFirstVisibleIndex(true); var last_visible = GetLastVisibleIndex(true); if (first_visible > index) { var item_starts = index * GetItemSize(); SetScrollValue(item_starts); } else if (last_visible < index) { var margin = (IsHorizontal()) ? layout.GetMarginLeft() : layout.GetMarginTop(); var item_ends = (index + 1) * GetItemSize() - GetItemSpacing() + margin - GetScrollSize(); SetScrollValue(item_ends); } }
/// <summary> /// Gets the left or top margin. /// </summary> /// <returns>The margin.</returns> public float GetMargin() { return(IsHorizontal ? Layout.GetMarginLeft() : Layout.GetMarginTop()); }
/// <summary> /// Gets the item position bottom. /// </summary> /// <returns>The item position bottom.</returns> /// <param name="index">Index.</param> protected virtual float GetItemPositionBottom(int index) { var margin = (IsHorizontal()) ? layout.GetMarginLeft() : layout.GetMarginTop(); return(GetItemPosition(index) + GetItemSize() - GetItemSpacing() + margin - GetScrollSize()); }