         let offsetX = scrollView.contentOffset.x - self.scrollPreviewPoint.x
         let offsetY = scrollView.contentOffset.y - self.scrollPreviewPoint.y
         
-        if offsetY > offsetX {
+        if self.scrollMode == .None {
+            if (offsetY > offsetX) {
+                self.scrollMode = .Vertical;
+            } else {
+                self.scrollMode = .Horizontal;
+            }
+        }
+        
+        if self.scrollMode == .Vertical {
             let alpha = 1.0 - (scrollView.contentOffset.y / (scrollView.frame.size.height / 2.0))
             self.backgroundView.alpha = alpha
             
             var contentOffset = scrollView.contentOffset
             contentOffset.x = self.scrollPreviewPoint.x
             scrollView.contentOffset = contentOffset
-        } else {
+        } else if self.scrollMode == .Horizontal {
             var contentOffset = scrollView.contentOffset
             contentOffset.y = self.scrollPreviewPoint.y
             scrollView.contentOffset = contentOffset

    case None = 0, Vertical, Horizontal
}



public class ViewController:UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {

    var collectionView: UICollectionView!

    var pageControl:UIPageControl!
    var backgroundView:UIView!
    var closeButton:UIButton!
    var scrollMode:PhotoSliderControllerScrollMode = .None

    public var delegate: PhotoSliderDelegate? = nil
    public var visiblePageControl = true
