AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

ASTableNode will scroll to the top after insert rows

Open IvanChan opened this issue 5 years ago • 0 comments

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)
      })

IvanChan avatar Apr 02 '19 14:04 IvanChan