]> git.pond.sub.org Git - eow/blob - static/dojo-release-1.1.1/dojox/fx/_core.js
add Dojo 1.1.1
[eow] / static / dojo-release-1.1.1 / dojox / fx / _core.js
1 if(!dojo._hasResource["dojox.fx._core"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.fx._core"] = true;
3 dojo.provide("dojox.fx._core");
4
5 dojox.fx._Line = function(start, end){
6         // summary: a custom _Line to accomodate multi-dimensional values
7         //      
8         // description: 
9         //      a normal dojo._Line is the curve, and does Line(start,end)
10         //      for propertyAnimation. as we make more complicatied animations, we realize
11         //      some properties can have 2, or 4 values relevant (x,y) or (t,l,r,b) for example 
12         //
13         //      this function provides support for those Lines, and is ported directly from 0.4
14         //      this is a lot of extra code for something so seldom used, so we'll put it here as
15         //      and optional core addition. you can create a new line, and use it during onAnimate
16         //      as you see fit.
17         //
18         // start: Integer|Array
19         //      An Integer (or an Array of integers) to use as a starting point
20         // end: Integer|Array
21         //      An Integer (or an Array of integers) to use as an ending point
22         //
23         // example: see dojox.fx.smoothScroll 
24         //
25         // example: 
26         // |    // this is 10 .. 100 and 50 .. 500
27         // |    var curve = new dojox.fx._Line([10,50],[100,500]);
28         // |    // dojo._Animation.onAnimate is called at every step of the animation
29         // |    // to define current values. this _Line returns an array
30         // |    // at each step. arguments[0] and [1] in this example. 
31         //
32         this.start = start;
33         this.end = end;
34         if(dojo.isArray(start)){
35                 // multi-dimensional branch
36                 var diff = [];
37                 dojo.forEach(this.start, function(s,i){
38                         diff[i] = this.end[i] - s;
39                 }, this);
40                 
41                 this.getValue = function(/*float*/ n){
42                         var res = [];
43                         dojo.forEach(this.start, function(s, i){
44                                 res[i] = (diff[i] * n) + s;
45                         }, this);
46                         return res; // Array
47                 }
48         }else{
49                 // single value branch, document here for both branches:
50                 var diff = end - start;
51                 this.getValue = function(/*float*/ n){
52                         // summary: Returns the point on the line, or an array of points
53                         // n: a floating point number greater than 0 and less than 1
54                         // returns: Mixed 
55                         return (diff * n) + this.start; // Decimal
56                 }
57         }
58 };
59
60 }