public void ChangePage(int pageDifferential) { Debug.Assert(this.modPage != null); if (this.m_isTransitioning) { return; } int pageSize = this.m_modPageContainer.itemLimit; if (pageSize < 0) { pageSize = APIPaginationParameters.LIMIT_MAX; } int targetPageIndex = this.m_modPage.CalculatePageIndex() + pageDifferential; int targetPageProfileOffset = targetPageIndex * pageSize; Debug.Assert(targetPageIndex >= 0); Debug.Assert(targetPageIndex < this.m_modPage.CalculatePageCount()); int pageItemCount = (int)Mathf.Min(pageSize, this.m_modPage.resultTotal - targetPageProfileOffset); RequestPage <ModProfile> transitionPlaceholder = new RequestPage <ModProfile>() { size = pageSize, items = new ModProfile[pageItemCount], resultOffset = targetPageProfileOffset, resultTotal = this.m_modPage.resultTotal, }; this.m_transitionPage = transitionPlaceholder; this.UpdateTransitionPageDisplay(); ModProfileRequestManager.instance.FetchModProfilePage(this.m_requestFilter, targetPageProfileOffset, pageSize, (page) => { if (this.m_transitionPage == transitionPlaceholder) { this.m_transitionPage = page; this.UpdateTransitionPageDisplay(); } if (this.m_modPage == transitionPlaceholder) { this.DisplayModPage(page); } }, null); PageTransitionDirection transitionDirection = (pageDifferential < 0 ? PageTransitionDirection.FromLeft : PageTransitionDirection.FromRight); this.InitiateTargetPageTransition(transitionDirection, null); this.UpdatePageButtonInteractibility(); }
public void ChangePage(int pageDifferential) { if (this.isTransitioning) { return; } int pageSize = this.itemsPerPage; int targetPageIndex = this.CurrentPageNumber - 1 + pageDifferential; int targetPageProfileOffset = targetPageIndex * pageSize; Debug.Assert(targetPageIndex >= 0); Debug.Assert(targetPageIndex < this.CurrentPageCount); int pageItemCount = (int)Mathf.Min(pageSize, this.currentPage.resultTotal - targetPageProfileOffset); RequestPage <ModProfile> targetPage = new RequestPage <ModProfile>() { size = pageSize, items = new ModProfile[pageItemCount], resultOffset = targetPageProfileOffset, resultTotal = this.currentPage.resultTotal, }; this.targetPage = targetPage; this.UpdateTargetPageDisplay(); ModProfileRequestManager.instance.FetchModProfilePage(this.GenerateRequestFilter(), targetPageProfileOffset, pageSize, (page) => { if (this.targetPage == targetPage) { this.targetPage = page; this.UpdateTargetPageDisplay(); } if (this.currentPage == targetPage) { this.currentPage = page; this.UpdateCurrentPageDisplay(); this.UpdatePageButtonInteractibility(); } }, null); PageTransitionDirection transitionDirection = (pageDifferential < 0 ? PageTransitionDirection.FromLeft : PageTransitionDirection.FromRight); this.InitiateTargetPageTransition(transitionDirection, () => { this.UpdatePageButtonInteractibility(); }); this.UpdatePageButtonInteractibility(); }
private static DoubleAnimation CreateAnimation(ViewFrame viewFrame, PageTransitionDirection direction) { var transitionTarget = viewFrame; // 初始化 Effect var effect = new TransitionSlideInEffect { Texture2 = new ImageBrush(TakeSnap(transitionTarget)), Progress = 0 }; switch (direction) { case PageTransitionDirection.LeftToRight: effect.SlideAmount = new Point(-1.0, 0.0); break; case PageTransitionDirection.RightToLeft: effect.SlideAmount = new Point(1.0, 0.0); break; case PageTransitionDirection.TopToBottom: effect.SlideAmount = new Point(0.0, -1.0); break; case PageTransitionDirection.BottomToTop: effect.SlideAmount = new Point(0.0, 1.0); break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } transitionTarget.Effect = effect; var doubleAnimation = new DoubleAnimation(0, 100, TimeSpan.FromMilliseconds(300)) { EasingFunction = new PowerEase() { EasingMode = EasingMode.EaseOut } }; doubleAnimation.Completed += (sender, args) => { transitionTarget.Effect = null; }; return(doubleAnimation); }
// ----------[ PAGE TRANSITIONS ]--------- public void InitiateTargetPageTransition(PageTransitionDirection direction, Action onTransitionCompleted) { if (!isTransitioning) { float mainPaneTargetX = contentPane.rect.width * (direction == PageTransitionDirection.FromLeft ? 1f : -1f); float transPaneStartX = mainPaneTargetX * -1f; currentPageContainer.anchoredPosition = Vector2.zero; targetPageContainer.anchoredPosition = new Vector2(transPaneStartX, 0f); StartCoroutine(TransitionPageCoroutine(mainPaneTargetX, transPaneStartX, this.pageTransitionTimeSeconds, onTransitionCompleted)); } #if DEBUG else { Debug.LogWarning("[mod.io] ModPages are already transitioning."); } #endif }