         if (lastContentOffsetX < scrollView.contentOffset.x) {
             
             println("moving >>>>>>>>")
-        } else if (lastContentOffsetX == scrollView.contentOffset.x) {
             
-            println("im in zero")
+            if (scrollView.contentOffset.x == endContentOffSet) {
+                
+                scrollRectToVisible(CGRectMake(frame.width, 0, frame.width, frame.height), animated: false)
+            }
+            
         } else {
             
             println("moving <<<<<<<<")
+            
+            if (scrollView.contentOffset.x == 0) {
+                
+                scrollRectToVisible(CGRectMake(endContentOffSet - frame.width, 0, frame.width, frame.height), animated: false)
+            }
         }
         
         lastContentOffsetX = scrollView.contentOffset.x
 
     }
-    
-    func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool){
-    }
-    
-    
 }

        for photo in photos {
            
            imageView = UIImageView(frame: CGRectMake(x, frame.origin.y, frame.size.width, frame.size.height))
            imageView!.image = photo
            
            x += frame.width
            
            addSubview(imageView!)
        }
        
        contentSize = CGSizeMake(x, imageView!.frame.size.height)
    }
    
    func addImage() {
        
    }
    
    func scrollViewDidScroll(scrollView: UIScrollView){
        /* Gets called when user scrolls or drags */
    }

    func scrollViewDidEndDecelerating(scrollView: UIScrollView){

    
    var lastContentOffsetX:CGFloat
    var imageView:UIImageView?
    var endContentOffSet:CGFloat
    
    init(frame: CGRect, photos: [UIImage?]) {
    
        lastContentOffsetX = 0
        endContentOffSet = 0
        UIScrollView(frame: frame)
        super.init(frame: frame)
        delegate = self
