       let to = layoutAttributes[upcomingIndexPath] else { return 0 }
     
     let toWidth = sizeCache.itemWidthSelected(for: upcomingPagingItem)
-    var distance = to.frame.midX - view.bounds.midX
+    var distance = to.center.x - view.bounds.midX
     
     if let currentIndexPath = dataStructure.indexPathForPagingItem(currentPagingItem),
       let from = layoutAttributes[currentIndexPath] {
       
-      let distanceToCenter = view.bounds.midX - from.frame.midX
-      let distanceBetweenCells = to.frame.midX - from.frame.midX
+      let distanceToCenter = view.bounds.midX - from.center.x
+      let distanceBetweenCells = to.center.x - from.center.x
       distance = distanceBetweenCells - distanceToCenter
       
       if sizeCache.implementsWidthDelegate {
         let fromWidth = sizeCache.itemWidth(for: currentPagingItem)
         
         if upcomingPagingItem < currentPagingItem {
-          distance = -(to.frame.width + (from.frame.midX - to.frame.maxX) - (toWidth / 2)) - distanceToCenter
+          distance = -(to.bounds.width + (from.center.x - (to.center.x + (to.bounds.width / 2))) - (toWidth / 2)) - distanceToCenter
         } else {
-          let toDiff = (toWidth - to.frame.width) / 2
-          distance = fromWidth + (to.frame.midX - from.frame.maxX) + toDiff - (from.frame.width / 2) - distanceToCenter
+          let toDiff = (toWidth - to.bounds.width) / 2
+          distance = fromWidth + (to.center.x - (from.center.x + (from.bounds.width / 2))) + toDiff - (from.bounds.width / 2) - distanceToCenter
         }
       }
     } else if sizeCache.implementsWidthDelegate {
-      let toDiff = toWidth - to.frame.width
+      let toDiff = toWidth - to.bounds.width
       distance += toDiff / 2
     }
     

      let to = layoutAttributes[upcomingIndexPath] else { return 0 }
    
    let toWidth = sizeCache.itemWidthSelected(for: upcomingPagingItem)
    let currentPosition = to.frame.origin.x + to.frame.width
    let width = view.contentOffset.x + view.bounds.width
    var distance = currentPosition - width
    

      if let currentIndexPath = dataStructure.indexPathForPagingItem(currentPagingItem),
        let from = layoutAttributes[currentIndexPath] {
        if upcomingPagingItem < currentPagingItem {
          let toDiff = toWidth - to.bounds.width
          distance += toDiff
        } else {
          let fromWidth = sizeCache.itemWidth(for: currentPagingItem)
          let fromDiff = from.bounds.width - fromWidth
          let toDiff = toWidth - to.bounds.width
          distance -= fromDiff
          distance += toDiff
        }
      } else {
        distance += toWidth - to.bounds.width
      }
    }
    
