         let from = layoutAttributes[currentIndexPath] {
         if upcomingPagingItem > currentPagingItem {
           let fromWidth = sizeCache.itemWidth(for: currentPagingItem)
-          let fromDiff = from.frame.width - fromWidth
+          let fromDiff = from.bounds.width - fromWidth
           distance -= fromDiff
         }
       }

      let to = layoutAttributes[upcomingIndexPath] else { return 0 }
    
    let toWidth = sizeCache.itemWidthSelected(for: upcomingPagingItem)
    var distance = to.frame.midX - 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
      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
        } else {
          let toDiff = (toWidth - to.frame.width) / 2
          distance = fromWidth + (to.frame.midX - from.frame.maxX) + toDiff - (from.frame.width / 2) - distanceToCenter
        }
      }
    } else if sizeCache.implementsWidthDelegate {
      let toDiff = toWidth - to.frame.width
      distance += toDiff / 2
    }
    

      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
      }
    }
    
