Skip to content

Commit 97649af

Browse files
committed
Updating sample project animation
1 parent 525ce56 commit 97649af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Example/TableFlipExample/TableViewController.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,15 @@ private extension TableViewController {
128128
self.tableView.animate(animation: customAnimation, completion: nil)
129129

130130
case .indexPaths:
131-
let evenIndices = (0..<self.dataSource.exampleItems.count).compactMap { return ($0 % 2 == 0) ? IndexPath(row: $0, section: 0) : nil }
131+
let groupedItems = Dictionary(grouping: (0..<self.dataSource.exampleItems.count), by: { $0 % 2 })
132+
133+
let oddIndices = groupedItems[1]?.compactMap { IndexPath(row: $0, section: 0) }
134+
let leftAnimation = TableViewAnimation.Cell.left(duration: 0.5)
135+
self.tableView.animate(animation: leftAnimation, indexPaths: oddIndices, completion: nil)
136+
137+
let evenIndices = groupedItems[0]?.compactMap { IndexPath(row: $0, section: 0) }
132138
let rightAnimation = TableViewAnimation.Cell.right(duration: 0.5)
133139
self.tableView.animate(animation: rightAnimation, indexPaths: evenIndices, completion: nil)
134-
135140
}
136141
}
137142

0 commit comments

Comments
 (0)