コード例 #1
0
 public virtual void OnBeginDrag(PointerEventData eventData)
 {
     base.OnBeginDrag(eventData);
     this.isDragging = true;
     this.mState     = ScrollAutoFit.State.Dragging;
     this.OnScrollBegin.Invoke();
 }
コード例 #2
0
ファイル: ScrollAutoFit.cs プロジェクト: zunaalabaya/TAC-BOT
 public void SetScrollToHorizontal(float pos)
 {
     this.mForceScroll    = true;
     this.mStartPos       = (float)this.get_content().get_anchoredPosition().x;
     this.mEndPos         = pos;
     this.mScrollAnimTime = 0.0f;
     this.mState          = ScrollAutoFit.State.Scrolling;
 }
コード例 #3
0
 public virtual void OnEndDrag(PointerEventData eventData)
 {
     base.OnEndDrag(eventData);
       this.isDragging = false;
       if (this.mForceScroll || (double) this.ItemScale == 0.0 || !this.UseAutoFit)
     return;
       this.mState = ScrollAutoFit.State.DragEnd;
 }
コード例 #4
0
 public override void OnBeginDrag(PointerEventData eventData)
 {
     this.mStartIdx = this.GetCurrent();
       base.OnBeginDrag(eventData);
       this.isDragging = true;
       this.mState = ScrollAutoFit.State.Dragging;
       this.OnScrollBegin.Invoke();
 }
コード例 #5
0
 private void UpdateWait()
 {
     if (!this.IsScrollNow || this.isDragging || this.mForceScroll)
     return;
       this.OnScrollBegin.Invoke();
       if ((double) this.ItemScale == 0.0 || !this.UseAutoFit)
     return;
       this.mState = ScrollAutoFit.State.DragEnd;
 }
コード例 #6
0
        private void Update()
        {
            if (!this.UseAutoFit)
            {
                return;
            }
            switch (this.mState)
            {
            case ScrollAutoFit.State.DragEnd:
                if (!this.isDragging && (double)Mathf.Abs(!this.IsHorizontal ? (float)this.get_velocity().y : (float)this.get_velocity().x) < (double)this.ItemScale)
                {
                    this.SetScrollTo((float)Mathf.RoundToInt((!this.IsHorizontal ? (float)this.get_content().get_anchoredPosition().y : (float)this.get_content().get_anchoredPosition().x) / this.ItemScale) * this.ItemScale);
                    break;
                }
                break;

            case ScrollAutoFit.State.Scrolling:
                if ((double)this.mScrollAnimTime >= 0.0)
                {
                    this.mScrollAnimTime += Time.get_deltaTime();
                    float   num = (double)this.FitTime <= 0.0 ? 1f : Mathf.Sin((float)((double)Mathf.Clamp01(this.mScrollAnimTime / this.FitTime) * 3.14159274101257 * 0.5));
                    Vector2 anchoredPosition = this.get_content().get_anchoredPosition();
                    if (this.IsHorizontal)
                    {
                        anchoredPosition.x = (__Null)(double)Mathf.Lerp(this.mStartPos, this.mEndPos, num);
                    }
                    else
                    {
                        anchoredPosition.y = (__Null)(double)Mathf.Lerp(this.mStartPos, this.mEndPos, num);
                    }
                    this.get_content().set_anchoredPosition(anchoredPosition);
                    if ((double)num >= 1.0)
                    {
                        this.mScrollAnimTime = -1f;
                        this.mState          = ScrollAutoFit.State.Wait;
                        this.OnScrollStop.Invoke();
                        this.StopMovement();
                        break;
                    }
                    break;
                }
                break;
            }
            this.mForceScroll = false;
        }
コード例 #7
0
 private void Update()
 {
     if (!this.UseAutoFit)
     return;
       switch (this.mState)
       {
     case ScrollAutoFit.State.Wait:
       this.UpdateWait();
       break;
     case ScrollAutoFit.State.Dragging:
       this.MoveContentRange();
       break;
     case ScrollAutoFit.State.DragEnd:
       if (!this.isDragging)
       {
     if (this.HorizontalMode)
     {
       if ((double) Mathf.Abs((float) this.get_velocity().x) < (double) this.ItemScale)
       {
         if (this.UseMoveRange)
         {
           this.SetScrollToHorizontal(this.GetNearIconPos());
           break;
         }
         this.SetScrollToHorizontal((float) this.GetCurrent() * this.ItemScale + this.Offset);
         break;
       }
       if (this.UseMoveRange && this.CheckSetScrollPos())
       {
         this.MoveContentRange();
         this.mScrollAnimTime = -1f;
         this.mState = ScrollAutoFit.State.Wait;
         this.OnScrollStop.Invoke();
         this.StopMovement();
         double nearIconPos = (double) this.GetNearIconPos();
         break;
       }
       break;
     }
     if ((double) Mathf.Abs((float) this.get_velocity().y) < (double) this.ItemScale)
     {
       this.SetScrollTo((float) Mathf.RoundToInt((float) this.get_content().get_anchoredPosition().y / this.ItemScale) * this.ItemScale + this.Offset);
       break;
     }
     break;
       }
       break;
     case ScrollAutoFit.State.Scrolling:
       if ((double) this.mScrollAnimTime >= 0.0)
       {
     this.mScrollAnimTime += Time.get_deltaTime();
     float num = (double) this.FitTime <= 0.0 ? 1f : Mathf.Sin((float) ((double) Mathf.Clamp01(this.mScrollAnimTime / this.FitTime) * 3.14159274101257 * 0.5));
     Vector2 anchoredPosition = this.get_content().get_anchoredPosition();
     if (this.HorizontalMode)
       anchoredPosition.x = (__Null) (double) Mathf.Lerp(this.mStartPos, this.mEndPos, num);
     else
       anchoredPosition.y = (__Null) (double) Mathf.Lerp(this.mStartPos, this.mEndPos, num);
     this.get_content().set_anchoredPosition(anchoredPosition);
     if ((double) num >= 1.0)
     {
       this.mScrollAnimTime = -1f;
       this.mState = ScrollAutoFit.State.Wait;
       this.OnScrollStop.Invoke();
       this.StopMovement();
       break;
     }
     break;
       }
       break;
       }
       this.mForceScroll = false;
 }