         // we link the inherited controller to make changes on the view and other values any time
         self.presentAnimation.MainController = self
         self.dismissAnimation.MainController = self
+        self.view.addSubview(self.peekViewForDismissedController)
+        self.peekViewForDismissedController.translatesAutoresizingMaskIntoConstraints = false
+        self.view.addConstraint(NSLayoutConstraint(
+            item: self.peekViewForDismissedController,
+            attribute: NSLayoutAttribute.Top,
+            relatedBy: NSLayoutRelation.Equal,
+            toItem: self.view,
+            attribute: NSLayoutAttribute.Top,
+            multiplier: 1,
+            constant: 0))
+        self.view.addConstraint(NSLayoutConstraint(
+            item: self.peekViewForDismissedController,
+            attribute: NSLayoutAttribute.Bottom,
+            relatedBy: NSLayoutRelation.Equal,
+            toItem: self.view,
+            attribute: NSLayoutAttribute.Bottom,
+            multiplier: 1,
+            constant: 0))
+        self.view.addConstraint(NSLayoutConstraint(
+            item: self.peekViewForDismissedController,
+            attribute: NSLayoutAttribute.Width,
+            relatedBy: NSLayoutRelation.Equal,
+            toItem: self.view,
+            attribute: NSLayoutAttribute.Width,
+            multiplier: 1,
+            constant: 0))
+        self.constraintForPeekView = NSLayoutConstraint(
+            item: self.peekViewForDismissedController,
+            attribute: NSLayoutAttribute.Left,
+            relatedBy: NSLayoutRelation.Equal,
+            toItem: self.view,
+            attribute: NSLayoutAttribute.Right,
+            multiplier: 1,
+            constant: 0)
+        self.view.addConstraint(self.constraintForPeekView)
+    }
+    override func viewDidAppear(animated: Bool) {
+        super.viewDidAppear(animated)
+        self.view.bringSubviewToFront(self.peekViewForDismissedController)
+        self.peekViewForDismissedController.backgroundColor = UIColor.redColor()
     }
     override func presentViewController(viewControllerToPresent: UIViewController, animated: Bool, completion: (() -> Void)?) {
         // delegate the present animation of the new controller to sidebarcontroller

    let presentInteraction = SidebarPresentInteraction()
    let dismissInteraction = SidebarDismissInteraction()
    
    var snapshotViewForDismissedController:UIView = UIView()
    var peekGapForDismissedController:CGFloat = 40
    var presentAnimationDuration:NSTimeInterval = 0.5
    var dismissAnimationDuration:NSTimeInterval = 0.5
    

        
        UIView.animateWithDuration(self.transitionDuration(transitionContext), animations: {
            
            fromViewController.view.frame = CGRectOffset(bounds, bounds.size.width-self.MainController.gapForPeekView, 0)
            
            }, completion: {
                finished in
                self.MainController.constraintForPeekView.constant = -self.MainController.gapForPeekView
                self.MainController.peekViewForDismissedController.addSubview(self.MainController.dismissedControllerView!)
                transitionContext.completeTransition(!transitionContext.transitionWasCancelled())
        })
    }
}
class SidebarPresentInteraction: UIPercentDrivenInteractiveTransition {
    var viewController: SidebarController!
    var snapController: UIViewController!
    var shouldCompleteTransition = false
    var transitionInProgress = false
    var width:CGFloat = 0.0
    
    func attachToViewController(viewController: UIViewController, snapController: UIViewController) {
        self.viewController = viewController as! SidebarController
        self.snapController = snapController
        self.width = self.viewController.view.frame.size.width
        setupGestureRecognizer(self.viewController.view)
