@@ -335,6 +335,7 @@ open class ScrollStack: UIScrollView {
335335 sourceRow. removeFromSuperview ( )
336336 }
337337 stackView. insertArrangedSubview ( sourceRow, at: destIndex)
338+ postInsertRow ( sourceRow, animated: false )
338339 }
339340
340341 guard animated else {
@@ -577,18 +578,22 @@ open class ScrollStack: UIScrollView {
577578 // Remove any duplicate cell with the same view
578579 removeRowFromStackView ( cellToRemove)
579580
581+ postInsertRow ( newRow, animated: animated, completion: completion)
582+
583+ return newRow
584+ }
585+
586+ private func postInsertRow( _ row: ScrollStackRow , animated: Bool , completion: ( ( ) -> Void ) ? = nil ) {
580587 // Setup separator visibility for the new cell
581- updateRowSeparatorVisibility ( newRow )
588+ updateRowSeparatorVisibility ( row )
582589
583590 // A cell can affect the visibility of the cell before it, e.g. if
584591 // `automaticallyHidesLastSeparator` is true and a new cell is added as the last cell, so update
585592 // the previous cell's separator visibility as well.
586- updateRowSeparatorVisibility ( rowBeforeRow ( newRow ) )
593+ updateRowSeparatorVisibility ( rowBeforeRow ( row ) )
587594
588595 // Animate visibility
589- animateCellVisibility ( newRow, animated: animated, hide: false , completion: completion)
590-
591- return newRow
596+ animateCellVisibility ( row, animated: animated, hide: false , completion: completion)
592597 }
593598
594599 private func updateRowSeparatorVisibility( _ row: ScrollStackRow ? ) {
0 commit comments