dojox/fx/ext-dojo/reverse.js

  • Provides:

    • dojox.fx.ext-dojo.reverse
  • Requires:

    • dojo.fx.easing in common in project dojo
    • dojo.fx in common in project dojo
  • dojo.Animation._reversed

    • summary
  • dojo.Animation.reverse

    • type
      Function
    • parameters:
      • keepPaused: (typeof Boolean)
        By default, calling reverse() will play the animation if
        it was paused. Pass in true to keep it paused (will have
        no effect if reverse is called while animation is playing).
      • reverseEase: (typeof Function )
        Function
        A function to use for the reverse easing. This allows for
        the possibility of custom eases that are not in the dojo.fx
        library.
    • source: [view]
        var playing = this.status() == "playing";
        this.pause();
        this._reversed = !this._reversed;
        var d = this.duration,
         sofar = d * this._percent,
         togo = d - sofar,
         curr = new Date().valueOf(),
         cp = this.curve._properties,
         p = this.properties,
         nm
        ;
        this._endTime = curr + sofar;
        this._startTime = curr - togo;

        
        if(playing){
         this.gotoPercent(togo / d)
        }
        for(nm in p){
         var tmp = p[nm].start;
         p[nm].start = cp[nm].start = p[nm].end;
         p[nm].end = cp[nm].end = tmp;
        }

        
        if(this._reversed){
         if(!this.rEase){
          this.fEase = this.easing;
          if(reverseEase){
           this.rEase = reverseEase;
          }else{
           // loop through dojo.fx.easing to find the matching ease
           var de = dojo.fx.easing, found, eName;
           for(nm in de){
            if(this.easing == de[nm]){
             // get ease's name
             found = nm; break;
            }
           }

           
           if(found){
            // find ease's opposite
            if(/InOut/.test(nm) || !/In|Out/i.test(nm)){
             this.rEase = this.easing;
            }else if(/In/.test(nm)){
             eName = nm.replace("In", "Out");
            }else{
             eName = nm.replace("Out", "In");
            }
            if(eName){
             this.rEase = dojo.fx.easing[eName];
            }
           }else{
            // default ease, and other's like linear do not have an opposite
            console.info("ease function to reverse not found");
            this.rEase = this.easing;
           }
          }

          
         }
         this.easing = this.rEase;
        }else{
         this.easing = this.fEase;
        }
        if(!keepPaused && this.status() != "playing"){
         this.play();
        }

        
        return this;
    • summary
      The key method added to an animation to enable reversal.
  • dojo.Animation._endTime

    • summary
  • dojo.Animation._startTime

    • summary
  • dojo.Animation.fEase

    • summary
  • dojo.Animation.rEase

    • summary
  • dojo.Animation.easing

    • summary
  • dojox.fx.ext-dojo.reverse

    • type
      Object
    • summary
  • dojox.fx.ext-dojo

    • type
      Object
    • summary
  • dojox.fx

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary