Debian Codegraph @

dojox/fx/_core.js

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