         
         var transform = CGAffineTransform.identity
         
-        if itemOffset<visibleCount+1 && itemOffset >= -1 {
-            centerX = width/2+itemOffset*configuration.spacingX
-            centerY = height/2+collectionView.contentOffset.y+itemOffset*configuration.spacingY
+        if itemOffset < visibleCount + 1 && itemOffset >= -1 {
+            centerX = width / 2 + itemOffset * configuration.spacingX
+            centerY = height / 2 + collectionView.contentOffset.y + itemOffset * configuration.spacingY
             
-            let scaleFactor = 1-itemOffset/CGFloat(visibleCount)*configuration.scaleFactor
+            let scaleFactor = 1 - itemOffset / CGFloat(visibleCount) * configuration.scaleFactor
             let scaleTransform = CGAffineTransform(scaleX: scaleFactor, y: scaleFactor)
             transform = scaleTransform
             
             attributes.isHidden = false
-            attributes.alpha = itemOffset+1
+            attributes.alpha = itemOffset + 1
         } else {
-            centerX = -width/2
-            centerY = -height/2
+            centerX = -width / 2
+            centerY = -height / 2
             
             attributes.isHidden = true
         }
         
-        attributes.center = CGPoint(x: centerX+configuration.offsetX,
-                                    y: centerY+configuration.offsetY)
+        attributes.center = CGPoint(x: centerX + configuration.offsetX,
+                                    y: centerY + configuration.offsetY)
         attributes.transform = transform
         //        print("item:\(item) itemOffset:\(itemOffset)")
         return attributes

            spacingY = spacing
        }
    }
    public var reversed: Bool = false
    
}

    }
    
    public func attributesForCollectionView(collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
        guard let attributes = super.layoutAttributesForItem(at: indexPath) else {
            return nil
        }
        
        let item = CGFloat(indexPath.item)
        let width = collectionView.bounds.size.width
        let height = collectionView.bounds.size.height
        let cellSize = configuration.cellSize
        let cellHeight = cellSize.height
        var visibleCount = configuration.visibleCount <= 0 ? CGFloat(cellCount) : CGFloat(min(configuration.visibleCount, cellCount))
        var centerX: CGFloat = 0.0
        var centerY: CGFloat = 0.0
        
