Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASTableNode - broken automaticallyAdjustsContentOffset - not working during scrolling #2080

Open
patryk-sredzinski opened this issue Apr 18, 2023 · 1 comment

Comments

@patryk-sredzinski
Copy link

patryk-sredzinski commented Apr 18, 2023

◽️When it happens:

Always, 100% reproducible

◽️Current Behavior:

If there is a scrolling animation, inserting rows before visible content still shifts the whole tableview. Works properly only when tableview is stoped.

◽️Expected Behavior:

If user is scrolling, or there is a scrolling animation the tableview contentOffset should have the content offset shifted properly when there are insertions above.

◽️Steps To Reproduce:

Sample code showing the issue:
https://gist.github.com/patryk-sredzinski/832008c265bff1d99e29dd22da844ecd

  1. Put this code in any Xcode project, setup this 'TestController' to launch
  2. Tapping on the button at the bottom 'Add Elements on Top' will insert 50 elements at sections 0-49
  3. Observe behavior working properly when there is no scrolling animation
  4. Swipe to begin scrolling
  5. Tap on 'Add Elements on Top' to insert new elements on top
  6. Observe content offset shifts.

◽️Environment:

iOS: 16.4.1
Texutre: 3.1.0

◽️Current result:

Short GIF:

Full video:
https://www.youtube.com/shorts/0KfDXZTsVWI

◽️Observations

I think this can be related to UITableView. Changing contentOffset there during scrolling seems to be ignored.
UICollectionView seems to allow changing contentOffset during scrolling, but ASCollectionNode does not have this flag.

Do you have any good solution to get this working properly?

@patryk-sredzinski
Copy link
Author

◽️Workaround

I've observed what truly happens when Texture is changing the content offset, and I am not so sure if that's the efficient way.

I have achieved a result that does not add any additional lag (which was happening using Texture) by creating a custom UICollectionViewFlowLayout and overriding

targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint) -> CGPoint

So I modify the contentOffset there based on the collection view updates

That works pretty damn good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant