 	let sourceList = SourceListController(nibName: "SourceList", bundle: nil)!
 	var lastWidth: CGFloat = 100
 	var duration: NSTimeInterval = 0.5
+	var widthConstraint: NSLayoutConstraint?
+	var animatingSidaber = false
 
 	override func awakeFromNib() {
 		let leftView = self.splitView.subviews[0] as NSView

		leftView.addSubview(sourceList.view)
		leftView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[sourceList(==leftView@250,>=150@1000)]", options: nil, metrics: nil, views: views))
		leftView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[sourceList]|", options: nil, metrics: nil, views: views))
	}
	
	func splitView(splitView: NSSplitView, canCollapseSubview subview: NSView) -> Bool {
		return subview == splitView.subviews[0] as NSObject
	}

	@IBAction func toggleSourceList(sender: AnyObject?) {


		if isOpen {
			lastWidth = sourceList.view.frame.size.width
			sourceView.removeConstraint(widthConstraint!)
		}

		animatingSidaber = true
		NSAnimationContext.runAnimationGroup({ context in
			context.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
			context.duration = self.duration

			self.splitView.animator().splitPosition = position
		}, completionHandler: {
			self.animatingSidaber = false
			if !isOpen {
				sourceView.addConstraint(self.widthConstraint!)
			}
		})
	}
}
