facebookarchive / AsyncDisplayKit

Smooth asynchronous user interfaces for iOS apps.
http://asyncdisplaykit.org
Other
13.4k stars 2.2k forks source link

ASTableNode will scroll to the top after insert rows #3348

Open IvanChan opened 5 years ago

IvanChan commented 5 years ago

AsdkDEMO.zip

Very simple demo

  1. load some data, like from 40 - 100
  2. and then insert rows at the beginning, 0- 39
  3. the ASTableNode just jump to the top after the insertion

The insertion code like below, I try to scroll after insertion, in demo seems ok, but my project got a much more complicated cell & safeAreaInset, its totally disaster

// Table scroll to the top after insert
    self.tableNode.insertRows(at: newIndexPaths, with: .none)

// This workaround looks ok just because the cell is simple in layout & rendering
     self.tableNode.performBatch(animated: false, updates: {
          self.tableNode.insertRows(at: newIndexPaths, with: .none)
      }, completion: { (finished) in
          self.tableNode.scrollToRow(at: newIndexPaths.last!, at: .top, animated: false)
      })