TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.

Home Page:https://texturegroup.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ASTableNode - broken automaticallyAdjustsContentOffset - not working during scrolling

patryk-sredzinski opened this issue · comments

◽️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?

◽️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