コード例 #1
0
        public async Task AnimateToPage(int index)
        {
            // really animate to new page ?
            if (_visiblePageIndex != index && _nextView == null && ItemsSource != null)
            {
                // get animation direction
                var translation = _visiblePageIndex < index ? Width : -Width;

                // indicate this is the one that is visible
                _visiblePageIndex = index;

                // save selected
                SelectedIndex = index;

                // get view to move to
                _nextView = (MycoView)ItemTemplate.CreateContent();
                _nextView.BindingContext = ItemsSource[index];
                _nextView.Parent         = this;
                _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));

                // setup the next view offscreen
                _nextView.TranslationX = translation;

                // view to set to once complete
                var targetView = _nextView;
                var oldView    = _currentView;

                // animate new in, ol dout
                await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut));

                // setup the current view
                _currentView = targetView;

                // null out old view
                oldView.Parent = null;
                oldView        = null;

                // allow next animation
                _nextView = null;
            }
        }
コード例 #2
0
ファイル: MycoPagingLayout.cs プロジェクト: roceh/MycoLayout
        public async Task AnimateToPage(int index)
        {
            // really animate to new page ?
            if (index >= 0 && index < Children.Count && _visiblePageIndex != index && _nextView == null)
            {
                // get animation direction
                var translation = _visiblePageIndex < index ? Width : -Width;

                // indicate this is the one that is visible
                _visiblePageIndex = index;

                // save selected
                SelectedIndex = index;

                // get view to move to
                _nextView           = Children[index];
                _nextView.IsVisible = true;
                _nextView.Layout(new Rectangle(0, 0, Bounds.Width, Bounds.Height));

                // setup the next view offscreen
                _nextView.TranslationX = translation;

                // view to set to once complete
                var targetView = _nextView;
                var oldView    = _currentView;

                // animate new in, ol dout
                await Task.WhenAll(_nextView.TranslateTo(0, 0, 250, Easing.CubicInOut), _currentView.TranslateTo(-translation, 0, 250, Easing.CubicInOut));

                // setup the current view
                _currentView = targetView;

                // null out old view
                oldView.IsVisible = false;

                // allow next animation
                _nextView = null;
            }
        }