~andreserl/maas/packaging_precise_rebase

« back to all changes in this revision

Viewing changes to debian/extras/jslibs/yui/anim-curve/anim-curve-debug.js

  • Committer: Andres Rodriguez
  • Date: 2013-03-20 18:12:30 UTC
  • mfrom: (145.2.22 precise.sru)
  • Revision ID: andreserl@ubuntu.com-20130320181230-6l5guc0nhlv2z4p7
Re-base againts latest quantal released branch towards SRU

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.5.1 (build 22)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
YUI.add('anim-curve', function(Y) {
 
8
 
 
9
/**
 
10
 * Adds support for the <code>curve</code> property for the <code>to</code> 
 
11
 * attribute.  A curve is zero or more control points and an end point.
 
12
 * @module anim
 
13
 * @submodule anim-curve
 
14
 */
 
15
 
 
16
Y.Anim.behaviors.curve = {
 
17
    set: function(anim, att, from, to, elapsed, duration, fn) {
 
18
        from = from.slice.call(from);
 
19
        to = to.slice.call(to);
 
20
        var t = fn(elapsed, 0, 100, duration) / 100;
 
21
        to.unshift(from);
 
22
        anim._node.setXY(Y.Anim.getBezier(to, t));
 
23
    },
 
24
 
 
25
    get: function(anim, att) {
 
26
        return anim._node.getXY();
 
27
    }
 
28
};
 
29
 
 
30
/**
 
31
 * Get the current position of the animated element based on t.
 
32
 * Each point is an array of "x" and "y" values (0 = x, 1 = y)
 
33
 * At least 2 points are required (start and end).
 
34
 * First point is start. Last point is end.
 
35
 * Additional control points are optional.     
 
36
 * @for Anim
 
37
 * @method getBezier
 
38
 * @static
 
39
 * @param {Array} points An array containing Bezier points
 
40
 * @param {Number} t A number between 0 and 1 which is the basis for determining current position
 
41
 * @return {Array} An array containing int x and y member data
 
42
 */
 
43
Y.Anim.getBezier = function(points, t) {  
 
44
    var n = points.length;
 
45
    var tmp = [];
 
46
 
 
47
    for (var i = 0; i < n; ++i){
 
48
        tmp[i] = [points[i][0], points[i][1]]; // save input
 
49
    }
 
50
    
 
51
    for (var j = 1; j < n; ++j) {
 
52
        for (i = 0; i < n - j; ++i) {
 
53
            tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
 
54
            tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1]; 
 
55
        }
 
56
    }
 
57
 
 
58
    return [ tmp[0][0], tmp[0][1] ]; 
 
59
 
 
60
};
 
61
 
 
62
 
 
63
}, '3.5.1' ,{requires:['anim-xy']});