             infinitePagePosition = maxInfinitePosition
         }
         
-        pagePosition = infinitePagePosition
+        return infinitePagePosition
     }
     
     /// Whether a position is infinitely scrolling between end ranges

    }
    
    /// Detect whether the scroll view is overscrolling while infinite scroll is enabled
    /// Adjusts pagePosition if required.
    ///
    /// - Parameter pagePosition: the relative page position.
    private func detectInfiniteOverscrollIfNeeded(pagePosition: inout CGFloat) {
        guard self.isInfinitelyScrolling(forPosition: pagePosition) else {
            return
        }
        
        let maxPagePosition = CGFloat((self.viewControllerCount ?? 1) - 1)


// MARK: - Calculations
private extension PageboyViewController {
    
    /// Calculate the new page position for a scroll view at its current offset.
    ///
    /// - Parameters:
    ///   - scrollView: Scroll view.
    ///   - currentIndex: Known current page index.
    /// - Returns: New page position & previous page position.
    private func calculateNewPagePosition(in scrollView: UIScrollView, currentIndex: PageIndex) -> (CGFloat, CGFloat)? {
        let (pageSize, contentOffset) = calculateRelativePageSizeAndContentOffset(for: scrollView)
        guard let scrollIndexDiff = self.pageScrollIndexDiff(forCurrentIndex: currentIndex,
                                                             expectedIndex: self.expectedTransitionIndex,
                                                             currentContentOffset: contentOffset,
                                                             pageSize: pageSize) else {
                                                                return nil
        }
        
        guard let pagePosition = calculatePagePosition(for: contentOffset,
                                                       pageSize: pageSize,
                                                       indexDiff: scrollIndexDiff) else {
                                                        return nil
        }
        
        // Return nil if previous position equals current
        let previousPagePosition = self.previousPagePosition ?? 0.0
        guard pagePosition != previousPagePosition else {
            return nil
        }
        
        return (pagePosition, previousPagePosition)
    }
    
    /// Calculate the relative page size and content offset for a scroll view at its current position.
    ///
