 
         
         
+        // hide the preview image
+        
+        imageView2.alpha = 0
+        
+        
         // load the asset image for the detail view
         
     

       // animator?.addBehavior(itemBehaviourPreview)
        
        // make the attachment not a bit off the center to provide some rotation
        attachment2 = UIAttachmentBehavior(item: imageView2!, offsetFromCenter: UIOffsetMake(0, 20),
                                           attachedToAnchor: CGPoint(x: -(screenWidth / 2) , y: screenHeight / 2 ))
        // create the intial attachment
        animator?.addBehavior(attachment2!)

            // next image
            if(velX > 1000){
                
                isImageTransition = true
                
                // reset the preview mode since we are loading a new image
                previewMode = previewStates.none
                
                // move the preview image into focus
                // remove old dynamic behaviour
                if let behaviour=attachment2{
                    animator?.removeBehavior(behaviour)
                }
                
                // snap back also the preview image
                // default case - just snap back
                snap2 = UISnapBehavior(item: imageView2, snapTo: CGPoint(x: screenWidth / 2, y: screenHeight / 2 ))
                snap2?.damping =  2
                animator?.addBehavior(snap2!)
                
                // reset the preview mode since we are loading a new image
                previewMode = previewStates.none
                ///////////////////////////////////////
                
                
                print("speed reached")
                gravity = UIGravityBehavior(items: [imageView])
                
                
           
                gravity?.gravityDirection = CGVector(dx: velX / 100, dy: velY / 100)
                
                animator?.addBehavior(gravity!)
               
                
                // append an action to the gravity
                // to observe if the image was moved 
                // off the visible screen and can be replaced by the previous image
                gravity!.action = { _ in
                    if (self.imageView.center.x > CGFloat(self.screenWidth * 12) ){
                        print("off screen for previous image")
                        
                        
                        self.animator?.removeAllBehaviors()
                        
                        self.isZoomMode = false;
                        self.loadPreviousImage()
                 
