コード例 #1
0
        /// <summary>
        /// Total height of items before and with specified index.
        /// </summary>
        /// <returns>The <see cref="System.Single"/>.</returns>
        /// <param name="index">Index.</param>
        float ItemEndAt(int index)
        {
            var height = DataSource.GetRange(0, index + 1).SumFloat(GetItemHeight);

            return(height + (LayoutBridge.GetSpacing() * index));
        }
コード例 #2
0
 /// <summary>
 /// Gets the item position bottom.
 /// </summary>
 /// <returns>The item position bottom.</returns>
 /// <param name="index">Index.</param>
 public override float GetItemPositionBottom(int index)
 {
     return(GetItemPosition(index) + DataSource[index].Height - LayoutBridge.GetSpacing() + LayoutBridge.GetMargin() - GetScrollSize());
 }
コード例 #3
0
 /// <summary>
 /// Gets the item position.
 /// </summary>
 /// <returns>The item position.</returns>
 /// <param name="index">Index.</param>
 public override float GetItemPosition(int index)
 {
     return(Mathf.Max(0, DataSource.GetRange(0, index).SumFloat(GetItemHeight) + (LayoutBridge.GetSpacing() * (index - 1))));
 }
コード例 #4
0
        /// <summary>
        /// Gets the item position bottom.
        /// </summary>
        /// <returns>The item position bottom.</returns>
        /// <param name="index">Index.</param>
        public override float GetItemPositionBottom(int index)
        {
            var block = Mathf.Min(GetBlockIndex(index) + 1, BlockSizes.Count);

            return(BlockSizes.GetRange(0, block).SumFloat() + (LayoutBridge.GetSpacing() * (block - 1)) + LayoutBridge.GetMargin() - GetScrollSize());
        }
コード例 #5
0
        /// <summary>
        /// Gets the item position.
        /// </summary>
        /// <returns>The item position.</returns>
        /// <param name="index">Index.</param>
        public override float GetItemPosition(int index)
        {
            var block = GetBlockIndex(index);

            return(BlockSizes.GetRange(0, block).SumFloat() + (LayoutBridge.GetSpacing() * block));
        }
コード例 #6
0
        /// <summary>
        /// Gets the index of the nearest item.
        /// </summary>
        /// <returns>The nearest item index.</returns>
        /// <param name="point">Point.</param>
        public override int GetNearestIndex(Vector2 point)
        {
            if (IsSortEnabled())
            {
                return(-1);
            }

            // block index
            var pos_block = IsHorizontal() ? point.x : -point.y;
            var block     = Mathf.RoundToInt(pos_block / GetItemSize());

            // item index in block
            var pos_elem = IsHorizontal() ? -point.y : point.x;
            var size     = (IsHorizontal()) ? itemHeight + LayoutBridge.GetSpacing() : itemWidth + LayoutBridge.GetSpacing();
            var k        = Mathf.FloorToInt(pos_elem / size);

            return(block * GetItemsPerBlock() + k);
        }