示例#1
0
    /// <summary>
    /// 将最后不可见的项移动到第一个
    /// </summary>
    /// <param name="firstItem"></param>
    protected virtual void ScrollUpDirection(RectTransform lastItem, RectTransform firstItem)
    {
        lastItem.SetAsFirstSibling();
        lastItem.anchoredPosition = new Vector2(firstItem.anchoredPosition.x, firstItem.anchoredPosition.y + ItemDistance);

        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];

        lastloopCircle.InitialedView(firstloopCircle.DataIndex - 1);

        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(lastItem, lastloopCircle);
        }
    }
    /// <summary>
    /// 将第一个不可见的项移动到末尾
    /// </summary>
    /// <param name="firstItem"></param>
    protected virtual void ScrollRightDirection(RectTransform firstItem, RectTransform lastItem)
    {
        //if (firstItem == null)
        //    firstItem = ContentRectrans.GetChildEX(0);

        firstItem.SetAsLastSibling();
        firstItem.anchoredPosition = new Vector2(lastItem.anchoredPosition.x + ItemDistance, lastItem.anchoredPosition.y);
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];
        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];

        firstloopCircle.InitialedView(lastloopCircle.DataIndex + 1);
        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(firstItem, firstloopCircle);
        }
    }
    /// <summary>
    ///将最后一个不可见得项移动到开头
    /// </summary>
    /// <param name="operateItem"></param>
    protected virtual void ScrollLeftDirection(RectTransform lastItem, RectTransform firstItem)
    {
        //if (lastItem == null)
        //    lastItem = ContentRectrans.GetChildEX(ContentRectrans.childCount - 1);
        lastItem.SetAsFirstSibling();
        lastItem.anchoredPosition = new Vector2(firstItem.anchoredPosition.x - ItemDistance, firstItem.anchoredPosition.y);

        LoopCircleItem lastloopCircle  = AllLoopCircleItems[lastItem];
        LoopCircleItem firstloopCircle = AllLoopCircleItems[firstItem];

        lastloopCircle.InitialedView(firstloopCircle.DataIndex - 1);
        if (OnItemShowAct != null)
        {
            OnItemShowAct.Invoke(lastItem, lastloopCircle);
        }
    }