         let minOffset = width - bounds.width
         if xOffset < minOffset {
             let diff = minOffset - xOffset
-            let newOffset = CGPoint(x: width + minOffset - diff, y: 0)
+            let newX = width + minOffset - diff
+            let newOffset = CGPoint(x: newX, y: 0)
             UIView.performWithoutAnimation {
                 setContentOffset(newOffset, animated: false)
             }

    
    private func prepareToResize() {
        let boundsCenter = CGPoint(x: bounds.midX, y: bounds.midY)
        pointToCenterAfterResize = convert(boundsCenter, to: imageView)
    }
    
    private func recoverFromResizing() {

        let maxOffset = width * 2
        if xOffset > maxOffset {
            let diff = xOffset - maxOffset
            let newX = width + diff
            let newOffset = CGPoint(x: newX, y: 0)
            UIView.performWithoutAnimation {
                setContentOffset(newOffset, animated: false)
            }
