Skip to content

Commit

Permalink
Updating sample project animation
Browse files Browse the repository at this point in the history
  • Loading branch information
mergesort committed Dec 31, 2018
1 parent 525ce56 commit 97649af
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Example/TableFlipExample/TableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,15 @@ private extension TableViewController {
self.tableView.animate(animation: customAnimation, completion: nil)

case .indexPaths:
let evenIndices = (0..<self.dataSource.exampleItems.count).compactMap { return ($0 % 2 == 0) ? IndexPath(row: $0, section: 0) : nil }
let groupedItems = Dictionary(grouping: (0..<self.dataSource.exampleItems.count), by: { $0 % 2 })

let oddIndices = groupedItems[1]?.compactMap { IndexPath(row: $0, section: 0) }
let leftAnimation = TableViewAnimation.Cell.left(duration: 0.5)
self.tableView.animate(animation: leftAnimation, indexPaths: oddIndices, completion: nil)

let evenIndices = groupedItems[0]?.compactMap { IndexPath(row: $0, section: 0) }
let rightAnimation = TableViewAnimation.Cell.right(duration: 0.5)
self.tableView.animate(animation: rightAnimation, indexPaths: evenIndices, completion: nil)

}
}

Expand Down

0 comments on commit 97649af

Please sign in to comment.