Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] FirstVisibleItemIndex is wrong when scrolling CollectionView on iOS #9989

Open
vikern22 opened this issue Mar 17, 2020 · 7 comments
Open
Labels
a/collectionview e/2 🕑 2 p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!

Comments

@vikern22
Copy link

vikern22 commented Mar 17, 2020

Description

When listening to the Scrolled-event on a CollectionView using LinearItemsLayout(ItemSpacing="10", Orientation="Vertical", SnapPointsAlignment="Start", SnapPointsType="Mandatory"), the ItemsViewScrolledEventArgs.FirstVisibleItemIndex returns an index 1 number lower than the actual value on the iOS platform. Seems to work fine on the Android platform.

Steps to Reproduce

  1. Run the attached sample
  2. Scroll the CollectionView

Expected Behavior

The Label below the CollectionView should display the index of the item aligned at the top.

Actual Behavior

The Label below the CollectionView displays 1 number lower than the expected value.

Basic Information

  • Version with issue: 4.5.0.396
  • Last known good version:
  • IDE: VS 2019 Enterprise
  • Platform Target Frameworks:
    • iOS: 13.3
    • Android: 10
  • Nuget Packages: NETStandard.Library, Xamarin.Essentials, Xamarin.Forms
  • Affected Devices: iPhone 11 Emulator, iPhone 7

Reproduction Link

https://drive.google.com/open?id=1Ci6NjRY9KvE3RbYSDZQ4f0pV1IsGY_LN

@vikern22 vikern22 added s/unverified New report that has yet to be verified t/bug 🐛 labels Mar 17, 2020
@pauldipietro pauldipietro added this to New in Triage Mar 17, 2020
@jfversluis
Copy link
Member

Adding the reproduction here on GitHub as well so we won't lose it.

Confirmed this is happening with the reproduction. I have played around with the ItemSpacing, margins, snapping etc. but that doesn't seem to matter. It's not until item 1 is scrolled halfway off the top of the screen before the FirstVisibleItemIndex goes to 1, while that value should be 1 as soon as item 0 was off screen.

@jfversluis jfversluis added a/collectionview e/2 🕑 2 p/iOS 🍎 and removed s/unverified New report that has yet to be verified labels Mar 17, 2020
@jfversluis jfversluis moved this from New to Ready For Work in Triage Mar 17, 2020
@samhouts samhouts added this to To do in iOS Ready For Work Mar 24, 2020
@samhouts samhouts removed this from Ready For Work in Triage Mar 24, 2020
@samhouts samhouts added this to Backlog in CollectionView Apr 10, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 14, 2020
@samhouts samhouts added inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! up-for-grabs We welcome community contributions to any issue, but these might be a good place to start! and removed inactive Issue is older than 6 months and needs to be retested help wanted We welcome community contributions to any issue, but these might be a good place to start! labels Sep 18, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@InquisitorJax
Copy link

This is pretty important for us to get code scrolling to work... anyone know of a work-around to get the first visible item index?

@hartez
Copy link
Contributor

hartez commented Feb 8, 2021

Repro9989.zip

@znelson32
Copy link

Really wish this wasn't an issue

@InquisitorJax
Copy link

It's a little ugly, but here's a work-around for iOS using a custom renderer
CollectionViewWorkAround.zip

@chaoyebugao
Copy link

With XF 5.0.0.2012, problem still exists.

@jlinker7
Copy link

Has anyone else found a viable work around for this? Using InquisitorJax's solution doesn't seem to work for me (The ScrollTo method no longer works). Have a horizontal list the user can scroll, or tap an arrow to move right and left one item at a time, this bug is keeping it from working well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/collectionview e/2 🕑 2 p/iOS 🍎 t/bug 🐛 up-for-grabs We welcome community contributions to any issue, but these might be a good place to start!
Projects
CollectionView
  
Backlog
Development

No branches or pull requests

8 participants