dojo/_base/fx.js

  • Provides:

    • dojo
  • dojo.__AnimArgs

    • type
      Function
    • chains:
      • dojo.__FadeArgs: (prototype)
      • dojo.__FadeArgs: (call)
    • summary
  • dojo.__AnimArgs.properties

    • type
      Object
    • summary
  • dojo._Animation

    • summary
  • timer

    • summary
  • runner

    • type
      Object
    • summary
  • PropLine.prototype.getValue

    • summary
  • dojo._Line

    • type
      Function
    • parameters:
      • start: (typeof int)
        Beginning value for range
      • end: (typeof int)
        Ending value for range
    • source: [view]
        this.start = start;
        this.end = end;
    • summary
      dojo._Line is the object used to generate values from a start value
      to an end value
  • dojo._Line.start

    • type
      int
    • summary
      Beginning value for range
  • dojo._Line.end

    • type
      int
    • summary
      Ending value for range
  • dojo._Line.getValue

    • type
      Function
    • parameters:
      • n: (typeof float)
        a floating point number greater than 0 and less than 1
    • source: [view]
        return ((this.end - this.start) * n) + this.start; // Decimal
    • summary
      Returns the point on the line
    • returns
      Decimal
  • dojo.Animation

    • type
      Function
    • parameters:
      • args: (typeof Object)
        The 'magic argument', mixing all the properties into this
        animation instance.
    • source: [view]
        _mixin(this, args);
        if(d.isArray(this.curve)){
         this.curve = new d._Line(this.curve[0], this.curve[1]);
        }
    • summary
      A generic animation class that fires callbacks into its handlers
      object at various states.
    • description
      A generic animation class that fires callbacks into its handlers
      object at various states. Nearly all dojo animation functions
      return an instance of this method, usually without calling the
      .play() method beforehand. Therefore, you will likely need to
      call .play() on instances of `dojo.Animation` when one is
      returned.
  • dojo.Animation.curve

    • summary
  • dojo._fade

    • type
      Function
    • parameters:
      • args: (typeof Object)
    • source: [view]
        args.node = d.byId(args.node);
        var fArgs = _mixin({ properties: {} }, args),
         props = (fArgs.properties.opacity = {});


        props.start = !("start" in fArgs) ?
         function(){
          return +d.style(fArgs.node, "opacity")||0;
         } : fArgs.start;
        props.end = fArgs.end;


        var anim = d.animateProperty(fArgs);
        d.connect(anim, "beforeBegin", d.partial(_makeFadeable, fArgs.node));


        return anim; // dojo.Animation
    • summary
      Returns an animation that will fade the node defined by
      args.node from the start to end values passed (args.start
      args.end) (end is mandatory, start is optional)
    • returns
      dojo.Animation
  • dojo.__FadeArgs

    • type
      Function
    • parameters:
      • node: (typeof DOMNode|String)
        The node referenced in the animation
      • duration: (typeof Integer)
        Duration of the animation in milliseconds.
      • easing: (typeof Function)
        An easing function.
    • source: [view]
        this.node = node;
        this.duration = duration;
        this.easing = easing;
    • summary
  • dojo.__FadeArgs.node

    • type
      DOMNode|String
    • summary
      The node referenced in the animation
  • dojo.__FadeArgs.duration

    • type
      Integer?
    • summary
      Duration of the animation in milliseconds.
  • dojo.__FadeArgs.easing

    • type
      Function?
    • summary
      An easing function.
  • dojo.fadeIn

    • type
      Function
    • parameters:
      • args: (typeof dojo.__FadeArgs)
    • source: [view]
        return d._fade(_mixin({ end: 1 }, args)); // dojo.Animation
    • summary
      Returns an animation that will fade node defined in 'args' from
      its current opacity to fully opaque.
    • returns
      dojo.Animation
  • dojo.fadeOut

    • type
      Function
    • parameters:
      • args: (typeof dojo.__FadeArgs)
    • source: [view]
        return d._fade(_mixin({ end: 0 }, args)); // dojo.Animation
    • summary
      Returns an animation that will fade node defined in 'args'
      from its current opacity to fully transparent.
    • returns
      dojo.Animation
  • dojo._defaultEasing

    • type
      Function
    • parameters:
      • n: (typeof Decimal)
    • source: [view]
        return 0.5 + ((Math.sin((n + 1.5) * Math.PI)) / 2);
    • summary
      The default easing function for dojo.Animation(s)
  • dojo.animateProperty

    • type
      Function
    • parameters:
      • args: (typeof dojo.__AnimArgs)
    • source: [view]
        var n = args.node = d.byId(args.node);
        if(!args.easing){ args.easing = d._defaultEasing; }


        var anim = new d.Animation(args);
        d.connect(anim, "beforeBegin", anim, function(){
         var pm = {};
         for(var p in this.properties){
          // Make shallow copy of properties into pm because we overwrite
          // some values below. In particular if start/end are functions
          // we don't want to overwrite them or the functions won't be
          // called if the animation is reused.
          if(p == "width" || p == "height"){
           this.node.display = "block";
          }
          var prop = this.properties[p];
          if(d.isFunction(prop)){
           prop = prop(n);
          }
          prop = pm[p] = _mixin({}, (d.isObject(prop) ? prop: { end: prop }));


          if(d.isFunction(prop.start)){
           prop.start = prop.start(n);
          }
          if(d.isFunction(prop.end)){
           prop.end = prop.end(n);
          }
          var isColor = (p.toLowerCase().indexOf("color") >= 0);
          function getStyle(node, p){
           // dojo.style(node, "height") can return "auto" or "" on IE; this is more reliable:
           var v = { height: node.offsetHeight, width: node.offsetWidth }[p];
           if(v !== undefined){ return v; }
           v = d.style(node, p);
           return (p == "opacity") ? +v : (isColor ? v : parseFloat(v));
          }
          if(!("end" in prop)){
           prop.end = getStyle(n, p);
          }else if(!("start" in prop)){
           prop.start = getStyle(n, p);
          }


          if(isColor){
           prop.start = new d.Color(prop.start);
           prop.end = new d.Color(prop.end);
          }else{
           prop.start = (p == "opacity") ? +prop.start : parseFloat(prop.start);
          }
         }
         this.curve = new PropLine(pm);
        });
        d.connect(anim, "onAnimate", d.hitch(d, "style", anim.node));
        return anim; // dojo.Animation
    • summary
      Returns an animation that will transition the properties of
      node defined in `args` depending how they are defined in
      `args.properties`
    • description
      `dojo.animateProperty` is the foundation of most `dojo.fx`
      animations. It takes an object of "properties" corresponding to
      style properties, and animates them in parallel over a set
      duration.
    • returns
      dojo.Animation
    • example
      A simple animation that changes the width of the specified node.
      
      	dojo.animateProperty({
      		node: "nodeId",
      		properties: { width: 400 },
      	}).play();
      Dojo figures out the start value for the width and converts the
      integer specified for the width to the more expressive but
      verbose form `{ width: { end: '400', units: 'px' } }` which you
      can also specify directly. Defaults to 'px' if ommitted.
    • example
      Animate width, height, and padding over 2 seconds... the
      pedantic way:
      
      	dojo.animateProperty({ node: node, duration:2000,
      		properties: {
      			width: { start: '200', end: '400', units:"px" },
      			height: { start:'200', end: '400', units:"px" },
      			paddingTop: { start:'5', end:'50', units:"px" }
      		}
      	}).play();
      Note 'paddingTop' is used over 'padding-top'. Multi-name CSS properties
      are written using "mixed case", as the hyphen is illegal as an object key.
    • example
      Plug in a different easing function and register a callback for
      when the animation ends. Easing functions accept values between
      zero and one and return a value on that basis. In this case, an
      exponential-in curve.
      
      	dojo.animateProperty({
      		node: "nodeId",
      		// dojo figures out the start value
      		properties: { width: { end: 400 } },
      		easing: function(n){
      			return (n==0) ? 0 : Math.pow(2, 10 * (n - 1));
      		},
      		onEnd: function(node){
      			// called when the animation finishes. The animation
      			// target is passed to this function
      		}
      	}).play(500); // delay playing half a second
    • example
      Like all `dojo.Animation`s, animateProperty returns a handle to the
      Animation instance, which fires the events common to Dojo FX. Use `dojo.connect`
      to access these events outside of the Animation definiton:
      
      	var anim = dojo.animateProperty({
      		node:"someId",
      		properties:{
      			width:400, height:500
      		}
      	});
      	dojo.connect(anim,"onEnd", function(){
      		console.log("animation ended");
      	});
      	// play the animation now:
      	anim.play();
    • example
      Each property can be a function whose return value is substituted along.
      Additionally, each measurement (eg: start, end) can be a function. The node
      reference is passed direcly to callbacks.
      
      	dojo.animateProperty({
      		node:"mine",
      		properties:{
      			height:function(node){
      				// shrink this node by 50%
      				return dojo.position(node).h / 2
      			},
      			width:{
      				start:function(node){ return 100; },
      				end:function(node){ return 200; }
      			}
      		}
      	}).play();
  • dojo.animateProperty.node.display

    • summary
  • dojo.animateProperty.curve

    • summary
  • dojo.anim

    • type
      Function
    • parameters:
      • node: (typeof DOMNode|String)
        a DOM node or the id of a node to animate CSS properties on
      • properties: (typeof Object)
      • duration: (typeof Integer)
        The number of milliseconds over which the animation
        should run. Defaults to the global animation default duration
        (350ms).
      • easing: (typeof Function)
        An easing function over which to calculate acceleration
        and deceleration of the animation through its duration.
        A default easing algorithm is provided, but you may
        plug in any you wish. A large selection of easing algorithms
        are available in `dojo.fx.easing`.
      • onEnd: (typeof Function)
        A function to be called when the animation finishes
        running.
      • delay: (typeof Integer)
        The number of milliseconds to delay beginning the
        animation by. The default is 0.
    • source: [view]
        return d.animateProperty({ // dojo.Animation
         node: node,
         duration: duration || d.Animation.prototype.duration,
         properties: properties,
         easing: easing,
         onEnd: onEnd
        }).play(delay || 0);
    • summary
      A simpler interface to `dojo.animateProperty()`, also returns
      an instance of `dojo.Animation` but begins the animation
      immediately, unlike nearly every other Dojo animation API.
    • description
      `dojo.anim` is a simpler (but somewhat less powerful) version
      of `dojo.animateProperty`.  It uses defaults for many basic properties
      and allows for positional parameters to be used in place of the
      packed "property bag" which is used for other Dojo animation
      methods.
      
      The `dojo.Animation` object returned from `dojo.anim` will be
      already playing when it is returned from this function, so
      calling play() on it again is (usually) a no-op.
    • returns
      dojo.Animation
    • example
      Fade out a node
      
      	dojo.anim("id", { opacity: 0 });
    • example
      Fade out a node over a full second
      
      	dojo.anim("id", { opacity: 0 }, 1000);
  • runner.run

    • type
      Function
    • source: [view]
      }
    • summary
  • dojo

    • type
      Object
    • summary