protected virtual void ScrollTo(ScrollToRequestEventArgs args)
        {
            var position = DetermineTargetPosition(args);

            if (args.IsAnimated)
            {
                ScrollHelper.AnimateScrollToPosition(position, args.ScrollToPosition);
            }
            else
            {
                ScrollHelper.JumpScrollToPosition(position, args.ScrollToPosition);
            }
        }
Beispiel #2
0
 protected override void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
 {
     if (Carousel?.Loop == true)
     {
         var goToIndexPath = Controller.GetScrollToIndexPath(args.Index);
         Controller.CollectionView.ScrollToItem(goToIndexPath,
                                                args.ScrollToPosition.ToCollectionViewScrollPosition(_layout.ScrollDirection),
                                                args.IsAnimated);
     }
     else
     {
         base.ScrollToRequested(sender, args);
     }
 }
Beispiel #3
0
        NSIndexPath DetermineIndex(ScrollToRequestEventArgs args)
        {
            if (args.Mode == ScrollToMode.Position)
            {
                if (args.GroupIndex == -1)
                {
                    return(NSIndexPath.Create(0, args.Index));
                }

                return(NSIndexPath.Create(args.GroupIndex, args.Index));
            }

            return(ItemsViewController.GetIndexForItem(args.Item));
        }
Beispiel #4
0
        protected virtual void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
        {
            using (var indexPath = DetermineIndex(args))
            {
                if (!IsIndexPathValid(indexPath))
                {
                    // Specified path wasn't valid, or item wasn't found
                    return;
                }

                ItemsViewController.CollectionView.ScrollToItem(indexPath,
                                                                args.ScrollToPosition.ToCollectionViewScrollPosition(_layout.ScrollDirection), args.IsAnimated);
            }
        }
Beispiel #5
0
        void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
        {
            var indexPath = DetermineIndex(args);

            if (indexPath.Row < 0 || indexPath.Section < 0)
            {
                // Nothing found, nowhere to scroll to
                return;
            }

            ItemsViewController.CollectionView.ScrollToItem(indexPath,
                                                            args.ScrollToPosition.ToCollectionViewScrollPosition(_layout.ScrollDirection),
                                                            args.IsAnimated);
        }
Beispiel #6
0
        // This is awkward.

        // Under certain circumstances, scrolling to an item in a group does not scroll all the way to the item; the
        // UICollectionView will stop short. This only happens when:
        // 1. The items are grouped
        // 2. The target scroll position is "End" or "MakeVisible"
        // 3. The ItemSizingStrategy is "MeasureAllItems" (i.e., we are using `estimatedItemSize` for the underlying
        //		UICollectionView, rather than setting `itemSize` or using `sizeForItemAtIndexPath`.)
        // 4. The item has never appeared on screen before

        // This may be an iOS bug.

        // To work around this, we check below for the right conditions and, it they are met, we simply call
        // ScrollToItem twice. The first time gets us close to the correct offset, the second time gets us all the way
        // there. If the scroll is _not_ animated, we can simply call it twice in a row; if it's animated, then we
        // have to wait for the first scroll to finish before calling the second one (`SetScrollAnimationEndedCallback`).

        protected override void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
        {
            if (WillNeedScrollAdjustment(args))
            {
                if (args.IsAnimated)
                {
                    Controller.SetScrollAnimationEndedCallback(() => base.ScrollToRequested(sender, args));
                }
                else
                {
                    base.ScrollToRequested(sender, args);
                }
            }

            base.ScrollToRequested(sender, args);
        }
        protected virtual async Task ScrollTo(ScrollToRequestEventArgs args)
        {
            if (!(Control is ListViewBase list))
            {
                return;
            }

            var targetItem = FindBoundItem(args);

            if (args.IsAnimated)
            {
                await AnimateTo(list, targetItem, args.ScrollToPosition);
            }
            else
            {
                await JumpTo(list, targetItem, args.ScrollToPosition);
            }
        }
Beispiel #8
0
        protected override void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
        {
            if (VirtualView?.Loop == true)
            {
                var goToIndexPath = (Controller as CarouselViewController).GetScrollToIndexPath(args.Index);

                if (!IsIndexPathValid(goToIndexPath))
                {
                    return;
                }

                Controller.CollectionView.ScrollToItem(goToIndexPath,
                                                       args.ScrollToPosition.ToCollectionViewScrollPosition(_layout.ScrollDirection),
                                                       args.IsAnimated);
            }
            else
            {
                base.ScrollToRequested(sender, args);
            }
        }
        protected override int DetermineTargetPosition(ScrollToRequestEventArgs args)
        {
            if (args.Mode == ScrollToMode.Element)
            {
                return(ItemsViewAdapter.GetPositionForItem(args.Item));
            }

            if (!Carousel.Loop)
            {
                return(args.Index);
            }

            if (_carouselViewLoopManager == null)
            {
                return(-1);
            }

            var carouselPosition = GetCarouselViewCurrentIndex(Carousel.Position);
            var getGoIndex       = _carouselViewLoopManager.GetGoToIndex(this, carouselPosition, args.Index);

            return(getGoIndex);
        }
Beispiel #10
0
        protected virtual async Task ScrollTo(ScrollToRequestEventArgs args)
        {
            if (!(Control is ListViewBase list))
            {
                return;
            }

            var item = FindBoundItem(args);

            if (item == null)
            {
                // Item wasn't found in the list, so there's nothing to scroll to
                return;
            }

            if (args.IsAnimated)
            {
                await ScrollHelpers.AnimateToItemAsync(list, item, args.ScrollToPosition);
            }
            else
            {
                await ScrollHelpers.JumpToItemAsync(list, item, args.ScrollToPosition);
            }
        }
Beispiel #11
0
 private void ItemsCollectionView_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
     // ItemsCollectionView.ScrollTo(viewModel.Items)
 }
Beispiel #12
0
 void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
 {
     ScrollTo(args);
 }
 public void AddPendingScrollTo(ScrollToRequestEventArgs args) => _pendingScrollTo.Enqueue(args);
Beispiel #14
0
 void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
 {
     (GetSnapManager()?.GetCurrentSnapHelper() as SingleSnapHelper)?.ResetCurrentTargetPosition();
     ScrollTo(args);
 }
Beispiel #15
0
 async void ScrollToRequested(object sender, ScrollToRequestEventArgs args)
 {
     await ScrollTo(args);
 }
 private void Ruler_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
 }
 private void Ruler_ScrollToRequested_1(object sender, ScrollToRequestEventArgs e)
 {
     Ruler.ScrollTo(e.Index);
 }
Beispiel #18
0
 private void collection_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
 }
Beispiel #19
0
 private void CarouselView_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
     Debug.WriteLine($"Scrolling to {e.Index}...");
 }
Beispiel #20
0
 private void CollectionView_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
     Console.WriteLine("ScrollToRequested : " + e.Index);
 }
Beispiel #21
0
 bool WillNeedScrollAdjustment(ScrollToRequestEventArgs args)
 {
     return(ItemsView.ItemSizingStrategy == ItemSizingStrategy.MeasureAllItems &&
            ItemsView.IsGrouped &&
            (args.ScrollToPosition == ScrollToPosition.End || args.ScrollToPosition == ScrollToPosition.MakeVisible));
 }
 public void Handle_ScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
     Debug.WriteLine(e.Item);
 }
Beispiel #23
0
 private void ItemsView_OnScrollToRequested(object sender, ScrollToRequestEventArgs e)
 {
 }