             }
         }
 
-        func yPosition(cell: UITableViewCell) -> CGFloat {
+        func yPosition(tableView: UITableView) -> CGFloat {
             if case .top = self {
-                return cell.frame.height
+                return -tableView.frame.height
             } else if case .bottom = self {
-                return -cell.frame.height
+                return tableView.frame.height
             } else {
                 return 0
             }


fileprivate extension UITableView {

    func animateTableViewWithTransform(duration: TimeInterval, transform: CGAffineTransform, staggered: Bool) {
        for (index, cell) in self.visibleCells.enumerated() {
            let delay: TimeInterval = staggered ? duration/Double(self.visibleCells.count)*Double(index) : 0.0
            let damping: CGFloat = staggered ? 0.55 : 0.75

                cell.alpha = 0.0
                UIView.animate(withDuration: duration, delay: animationDelay, options: .curveEaseInOut, animations: {
                    cell.alpha = 1.0
                }, completion: { finished in
                    completion?()
                })
            }
        } else {
            let animation = UITableView.fadeAnimationTransition
            animation.duration = duration

            self.layer.add(animation, forKey: "UITableViewReloadDataAnimationKey")

            DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + DispatchTimeInterval.milliseconds(Int(duration*1000))) {
                completion?()
            }
        }
    }

