     }
     
     public func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
-        return true
+        var shouldStartLoad = true
+        
+        switch navigationType {
+        case .LinkClicked:
+            animatePushState()
+        default:
+            break
+        }
+        
+        return shouldStartLoad
     }
     
     public func webView(webView: UIWebView, didFailLoadWithError error: NSError) {
         println("WebViewController Error: \(error)")
     }
 }
+
+// MARK: - UIWebView History
+
+extension WebViewController {
+    
+    func popState() {
+        webView.goBack()
+    }
+    
+    func onPushState() {
+        if shouldAnimateHistoryChange {
+            animatePushState()
+        }
+    }
+    
+    func onPopState() {
+        
+    }
+    
+    func animatePushState() {
+        placeholderImageView.image = view.captureImage()
+        webView.hidden = true
+        
+        let webViewController = WebViewController(webView: webView)
+        navigationController?.pushViewController(webViewController, animated: true)
+    }
+}
+
+
+// MARK: - Utils
+
+extension UIView {
+    
+    func captureImage() -> UIImage {
+        UIGraphicsBeginImageContextWithOptions(bounds.size, opaque, 0.0)
+        layer.renderInContext(UIGraphicsGetCurrentContext())
+        let image = UIGraphicsGetImageFromCurrentImageContext()
+        UIGraphicsEndImageContext()
+        return image
+    }
+}


import Foundation

public class WebViewController: UIViewController {
    
    var webView: UIWebView? {
        didSet {
            webView?.delegate = self
        }
    }
    
    private(set) public var url: NSURL?
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        
        webView = UIWebView(frame: self.view.frame)
        webView?.delegate = self
        view.addSubview(webView!)

    }

    required public init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    deinit {
        if webView?.delegate === self {
            self.webView?.delegate = nil
        }
    }
}

// MARK: - UIViewController

extension WebViewController {
    
    override public func viewDidLoad() {
        super.viewDidLoad()
    }
}


    
    public func loadURL(url: NSURL) {
        let request = NSURLRequest(URL: url)
        self.webView.loadRequest(request)
    }
}

