     }
     
     @discardableResult
-    private func placeNewCellOnRight(with rightEdge: CGFloat) -> CGFloat {
-        let view = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
-        view.text = "aaaaaaaaaaaaaaaa"
+    private func placeNewCellOnRight(with rightEdge: CGFloat, index: Int) -> CGFloat {
+        let view = PagingMenuCell(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
+        view.index = (index + 1) % numberOfItem
         containerView.addSubview(view)
         
         visibleCell.append(view)

        return view.frame.maxX
    }
    
    private func placeNewCellOnLeft(with leftEdge: CGFloat) -> CGFloat {
        let view = UILabel(frame: CGRect(x: 0, y: 0, width: 100, height: 50))
        view.text = "aaaaaaaaaaaaaaaa"
        containerView.addSubview(view)
        
        visibleCell.insert(view, at: 0)
        view.frame.origin.x = leftEdge - frame.size.width
        view.frame.origin.y = containerView.bounds.size.height - view.frame.size.height
        return view.frame.minX
    }
    
    private func tileCell(from minX: CGFloat, to maxX: CGFloat) {
        if visibleCell.isEmpty {
            placeNewCellOnRight(with: minX)
        }
        
        if let lastCell = visibleCell.last {
            var rightEdge = lastCell.frame.maxX
            while rightEdge > maxX {
                rightEdge = placeNewCellOnRight(with: rightEdge)
            }
        }
        
        if let firstCell = visibleCell.first {
            var leftEdge = firstCell.frame.minX
            while leftEdge > minX {
                leftEdge = placeNewCellOnLeft(with: leftEdge)
            }
        }
        
        var removeVisibleCell = visibleCell
        for (idx, cell) in visibleCell.enumerated() where cell.frame.minX > maxX {
            cell.removeFromSuperview()
            removeVisibleCell.remove(at: idx)
        }

        for (idx, cell) in visibleCell.enumerated() where cell.frame.maxX > minX {
            cell.removeFromSuperview()
            removeVisibleCell.remove(at: idx)
        }
    }
    
    
}

        tileCell(from: visibleBounds.minX, to: visibleBounds.maxX)
    }
    
    var numberOfItem: Int = 0
    
    public func reloadData() {
        guard let dataSource = dataSource else {
            return
        }
        
        numberOfItem = dataSource.numberOfItemForPagingMenuView()
        let containerWidth = bounds.width * CGFloat(numberOfItem)
        contentSize = CGSize(width: containerWidth, height: bounds.height)
        containerView.frame = CGRect(origin: .zero, size: contentSize)
        containerView.center = CGPoint(x: contentSize.width/2, y: contentSize.height/2)
        
        setNeedsLayout()
        layoutIfNeeded()
    }
    
    private func recenterIfNeeded() {
        let currentOffset = contentOffset
        let contentWidth = contentSize.width
        let centerOffsetX = (contentWidth - bounds.size.width) / 2
        let distanceFromCenter = fabs(currentOffset.x - centerOffsetX)
        
        if distanceFromCenter > contentWidth / 4 {
