f0ff6a3352fa4762a329f890a28fd437ba0a1bd0.svn-base 2.2 KB

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