 class ViewController: UIViewController {
 
     let DEFAULT_BACKGROUND_IMAGE = "2801-11"
+    let REFERENCE_ANIMATION_DURATION = 40
+    let REFERENCE_ANIMATION_FAST_RETURN_DURATION = 3
+    let REFERENCE_MAX_TRAILING_CONTRAINT_CONSTANT = -400
+    
     
     enum direction
     {

            completion: { finished in
                self.secondElapse = self.secondElapse! + 1
                self.lastPosToReach = self.backImageTrailingConstraint.constant
                println("      ... 1 sec elapsed" +
                        "\ncurrent constraint constant : \(self.lastPosToReach)" +
                        "\ncurrent time elapsed since animation started in this direction : \(self.secondElapse)" +
                        "\n")
                
            }
        )

        
    }
    
    func AnimationFastReturnZeroPoint()
    {
        println("\n-> animation zero point return")
        
        
        var duration = NSTimeInterval(REFERENCE_ANIMATION_FAST_RETURN_DURATION)
        self.backImageTrailingConstraint.constant = ZERO_TRAILLING_CONSTRAINT
        
//        println("Objective constraint.constant: \(self.backImageTrailingConstraint.constant)" +
//            "\nFor duration (in seconds) : \(duration)")
        
        UIView.animateWithDuration(duration
            , delay: 0.0
            , options: UIViewAnimationOptions.CurveLinear
            , animations:
            {
                
                self.view.layoutIfNeeded()
                //layoutIfNeeded is not animated, the trick to animate is to set alpha to 1.0 as it is already
                self.view.alpha = 1.0
            },
            completion: { finished in
           
                //resume timer, and start animation per seconds :
                
                self.timer1 = NSTimer(timeInterval: 1.0, target: self, selector: Selector("AnimationBackGroundParSeconde"), userInfo: nil, repeats: true)
                NSRunLoop.mainRunLoop().addTimer(self.timer1!, forMode:NSDefaultRunLoopMode)
                
            }
        )

        
    }
    

    func AnimationBackGroundParSeconde()
    {
        println("\n-> animation for 1 second")
        if self.secondElapse! == 40
        {
            println("##### <-> CHANGE direction #####")
            //self.lastDirection == direction.toLeft ? direction.toLeft : direction.toRight
            
            if self.lastDirection == direction.toLeft
            {
               self.lastDirection = direction.toRight
            }
            else
            {
                self.lastDirection = direction.toLeft
            }

            self.secondElapse = 0
        }
        else
        {
            println("##### -> SAME direction #####")
        }
        var directionString = "from right to left"
        if lastDirection == direction.toRight{
            directionString = "from left to right"
        }
        println("                        DIRECTION : \(directionString)")
        
        
        var duration = NSTimeInterval(REFERENCE_ANIMATION_DURATION)
        self.backImageTrailingConstraint.constant = CGFloat(REFERENCE_MAX_TRAILING_CONTRAINT_CONSTANT)
        
        println(" -- Objective constraint.constant: \(self.backImageTrailingConstraint.constant)" +
                            "\n -- For duration (in seconds) : \(duration)")
       
        UIView.animateWithDuration(duration
            , delay: 0.0
