         
         scrollDirection = .horizontal
         collectionView?.decelerationRate = UIScrollViewDecelerationRateNormal
-     
+
     }
     
     override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {
         var newOffset = CGPoint()
         
         let layout = collectionView!.collectionViewLayout as! AJMFlowLayout
-        let width = itemSize.width + layout.minimumLineSpacing
         
+        let firstItemPosX = layoutAttributesForItem(at: IndexPath(item: 0, section: 0))!.frame.origin.x
+        let secondItemPosX = layoutAttributesForItem(at: IndexPath(item: 0, section: 1))!.frame.origin.x
+        
+        let spacing = secondItemPosX - firstItemPosX - itemSize.width
+
+        let width = itemSize.width + spacing
+        print("\(spacing)")
         var offset = proposedContentOffset.x
         print("Imprimiendo \(velocity) \(width) - \(offset)")
 

            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.7 {
                    attribute.alpha = 1
                } else {
                    attribute.alpha = attribute.alpha*percent

    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        itemSize = CGSize(width: 300, height: 300)
    }
    
    override func prepare() {
