             
         }
     }
+    
+    func addRotateEffect(attribute : UICollectionViewLayoutAttributes, percent : CGFloat) {
+        // create 3D effect
+        var transform = CATransform3DIdentity
+        transform.m34 = -1.0 / 500.0
+        transform = CATransform3DRotate(transform, CGFloat(M_PI_4) * percent, 0, 1, 0)
+        if attribute.indexPath.section != 0 {
+            if percent >= 0.5 {
+                attribute.alpha = 1
+            } else {
+                attribute.alpha = 0
+            }
+        }
+        
+        attribute.transform3D = transform
+    }
 }

    func setUpInitialPositionForLayoutAttributes(_ attributes : [UICollectionViewLayoutAttributes]) {
        
        for attr in attributes {
            if let _ = allAttributes[attr.indexPath] {
                
            } else {
                
                let posY = (collectionView!.bounds.height - itemSize.height) / 2
                attr.frame = CGRect(x: attr.frame.origin.x, y: posY, width: itemSize.width, height: itemSize.height)

    
    override func prepare() {
        super.prepare()
        scrollDirection = .horizontal
        collectionView?.decelerationRate = UIScrollViewDecelerationRateFast
    }
    

    override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? {
        
        let array = super.layoutAttributesForElements(in: rect)!
