 				}
 
 				if let closestChildIndex = closestChildIndex {
-					newContentOffset = CGPoint(left: (CGFloat(closestChildIndex) - closestChildOffset) * viewBounds.width, top: 0)
+					newContentOffset = CGPoint(left: (CGFloat(closestChildIndex) - closestChildOffset) * bounds.width, top: 0)
 				}
 				else if let primaryViewController = primaryViewController, let index = viewControllers.indexOfIdentical(primaryViewController) {
-					newContentOffset = CGPoint(left: (CGFloat(index) * viewBounds.width), top: 0)
+					newContentOffset = CGPoint(left: (CGFloat(index) * bounds.width), top: 0)
 				}
 			}
 


		let visibleIndexes: Range<Int>

		if viewControllers.isEmpty || viewBounds.isEmpty {
			visibleIndexes = 0 ..< 0
		}
		else {
			let floatingIndex = contentOffset.left / viewBounds.width
			visibleIndexes = Int(floor(floatingIndex)).clamp(min: 0, max: viewControllers.count - 1) ... Int(ceil(floatingIndex)).clamp(min: 0, max: viewControllers.count - 1)
		}


	public override func viewDidLayoutSubviewsWithAnimation(animation: Animation?) {
		super.viewDidLayoutSubviewsWithAnimation(animation)

		let bounds = view.bounds
		guard bounds.size != lastLayoutedSize else {
			return
		}

		lastLayoutedSize = bounds.size

		layoutChildrenForcingLayoutUpdate(false)
		updatePrimaryViewController()
	}

