 	
 	override func viewWillAppear(animated: Bool) {
 		super.viewWillAppear(animated)
-		view.addGestureRecognizer(pinchGestureRecognizer)
-		
-		layout.itemSize = computeItemSize()
-		layout.invalidateLayout()
-		collectionView.reloadData()
+		myView.viewWillAppear()
 	}
 
 	override func viewDidDisappear(animated: Bool) {
 		super.viewDidDisappear(animated)
-		view.removeGestureRecognizer(pinchGestureRecognizer)
-	}
-	
-	lazy var layout: FlowLayout = {
-		return self.createFlowLayout()
-	}()
-	
-	func computeItemSize() -> CGSize {
-		return CGSize(width: model.scaleRounded, height: CollectionViewModel.height)
-	}
-	
-	func createFlowLayout() -> FlowLayout {
-		let instance = FlowLayout()
-		instance.itemSize = computeItemSize()
-		instance.model = self.model
-		return instance
-	}
-	
-	lazy var collectionView: MyCollectionView = {
-		let instance = MyCollectionView(frame: CGRectZero, collectionViewLayout: self.layout)
-		instance.delegate = self
-		instance.dataSource = self
-		return instance
-	}()
-	
-	func scrollViewDidScroll(scrollView: UIScrollView) {
-		updateLabel()
-	}
-	
-	func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
-		return model.count
-	}
-	
-	func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
-		let cell = collectionView.dequeueReusableCellWithReuseIdentifier(SliderCell.identifier, forIndexPath: indexPath) as! SliderCell
-		cell.label.text = String(indexPath.row % 10)
-		return cell
-	}
-}
+		myView.viewDidDisappear()
+	}
+}

	}
	
	lazy var pinchGestureRecognizer: UIPinchGestureRecognizer = {
		let instance = UIPinchGestureRecognizer(target: self, action: #selector(ScientificSliderViewController2.handlePinch))
		instance.delegate = self
		return instance
	}()

	}
	
	func commonInit() {
		backgroundColor = UIColor.whiteColor()
		addSubview(leftBorder)
		addSubview(label)
	}
	
	lazy var leftBorder: UIView = {
		let instance = UIView()
		instance.backgroundColor = UIColor.blackColor()
		return instance
	}()
	
	lazy var label: UILabel = {
		let instance = UILabel()
		instance.text = "0"
		return instance
	}()
	
	override func layoutSubviews() {
		super.layoutSubviews()
		leftBorder.frame = CGRect(x: 0, y: 0, width: 1, height: bounds.height)
		
		let labelHidden = self.bounds.width < 30
		label.hidden = labelHidden

		label.sizeToFit()
		let labelFrame = label.frame
		label.frame = CGRect(x: 7, y: 5, width: bounds.width - 10, height: labelFrame.height)
	}
}

class MyView: UIView, UICollectionViewDelegateFlowLayout, UICollectionViewDataSource, UIScrollViewDelegate, UIGestureRecognizerDelegate {
	var originalScale: CGFloat = 1.0
	var originalValue: CGFloat?
	
	typealias ValueDidChange = Void -> Void
	var valueDidChange: ValueDidChange?

	override init(frame: CGRect) {
		super.init(frame: frame)
		commonInit()
	}
	required init?(coder aDecoder: NSCoder) {
		super.init(coder: aDecoder)
		commonInit()
	}

	func commonInit() {
		addSubview(collectionView)
		addSubview(leftCoverView)
		addSubview(rightCoverView)
	}
	
	func viewWillAppear() {
		addGestureRecognizer(pinchGestureRecognizer)
		
		layout.itemSize = computeItemSize()
		layout.invalidateLayout()
		collectionView.reloadData()
	}
	
	func viewDidDisappear() {
		removeGestureRecognizer(pinchGestureRecognizer)
	}
	
	override func layoutSubviews() {
		super.layoutSubviews()
		collectionView.frame = bounds
		
		let halfWidth = round(bounds.width/2)-1
		collectionView.contentInset = UIEdgeInsets(top: 0, left: halfWidth, bottom: 0, right: halfWidth)

		let (leftFrame, rightFrame) = bounds.divide(round(bounds.width/2), fromEdge: .MinXEdge)
		leftCoverView.frame = CGRect(x: leftFrame.origin.x, y: leftFrame.origin.y, width: leftFrame.size.width - 1, height: leftFrame.size.height)
		rightCoverView.frame = rightFrame
	}

	lazy var leftCoverView: UIView = {
		let instance = UIView()
		instance.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.2)
