~ted/lazr-js/annoying-debug-message

« back to all changes in this revision

Viewing changes to src-js/lazrjs/yui/anim/anim-base.js

  • Committer: Launchpad Patch Queue Manager
  • Date: 2010-09-09 14:20:30 UTC
  • mfrom: (182.1.3 yui-3.2)
  • Revision ID: launchpad@pqm.canonical.com-20100909142030-13w6vo0ixfysxc15
[r=beuno] Update lazr-js to yui-3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3
3
Code licensed under the BSD License:
4
4
http://developer.yahoo.com/yui/license.html
5
 
version: 3.1.2
6
 
build: 56
 
5
version: 3.2.0
 
6
build: 2676
7
7
*/
8
8
YUI.add('anim-base', function(Y) {
9
9
 
62
62
        NUM = Number;
63
63
 
64
64
    var _running = {},
65
 
        _instances = {},
66
65
        _timer;
67
66
 
68
67
    Y.Anim = function() {
69
68
        Y.Anim.superclass.constructor.apply(this, arguments);
70
 
        _instances[Y.stamp(this)] = this;
 
69
        Y.Anim._instances[Y.stamp(this)] = this;
71
70
    };
72
71
 
73
72
    Y.Anim.NAME = 'anim';
74
73
 
 
74
    Y.Anim._instances = {};
 
75
 
75
76
    /**
76
77
     * Regex of properties that should use the default unit.
77
78
     *
124
125
     * @static
125
126
     */
126
127
    Y.Anim.DEFAULT_SETTER = function(anim, att, from, to, elapsed, duration, fn, unit) {
127
 
        unit = unit || '';
128
 
        anim._node.setStyle(att, fn(elapsed, NUM(from), NUM(to) - NUM(from), duration) + unit);
 
128
        var node = anim._node,
 
129
            val = fn(elapsed, NUM(from), NUM(to) - NUM(from), duration);
 
130
 
 
131
        if (att in node._node.style || att in Y.DOM.CUSTOM_STYLES) {
 
132
            unit = unit || '';
 
133
            node.setStyle(att, val + unit);
 
134
        } else if (node._node.attributes[att]) {
 
135
            node.setAttribute(att, val);
 
136
        } else {
 
137
            node.set(att, val);
 
138
        }
129
139
    };
130
140
 
131
141
    /**
134
144
     * @property DEFAULT_GETTER
135
145
     * @static
136
146
     */
137
 
    Y.Anim.DEFAULT_GETTER = function(anim, prop) {
138
 
        return anim._node.getComputedStyle(prop);
 
147
    Y.Anim.DEFAULT_GETTER = function(anim, att) {
 
148
        var node = anim._node,
 
149
            val = '';
 
150
 
 
151
        if (att in node._node.style || att in Y.DOM.CUSTOM_STYLES) {
 
152
            val = node.getComputedStyle(att);
 
153
        } else if (node._node.attributes[att]) {
 
154
            val = node.getAttribute(att);
 
155
        } else {
 
156
            val = node.get(att);
 
157
        }
 
158
 
 
159
        return val;
139
160
    };
140
161
 
141
162
    Y.Anim.ATTRS = {
313
334
     * @static
314
335
     */    
315
336
    Y.Anim.run = function() {
316
 
        for (var i in _instances) {
317
 
            if (_instances[i].run) {
318
 
                _instances[i].run();
 
337
        var instances = Y.Anim._instances;
 
338
        for (var i in instances) {
 
339
            if (instances[i].run) {
 
340
                instances[i].run();
319
341
            }
320
342
        }
321
343
    };
331
353
                _running[i].pause();
332
354
            }
333
355
        }
 
356
 
334
357
        Y.Anim._stopTimer();
335
358
    };
336
359
 
413
436
        /**
414
437
         * Stops the animation and resets its time.
415
438
         * @method stop
 
439
         * @param {Boolean} finish If true, the animation will move to the last frame
416
440
         * @chainable
417
441
         */    
418
442
        stop: function(finish) {
453
477
        _resume: function() {
454
478
            this._set(PAUSED, false);
455
479
            _running[Y.stamp(this)] = this;
 
480
            this._set(START_TIME, new Date() - this.get(ELAPSED_TIME));
 
481
            Y.Anim._startTimer();
456
482
 
457
483
            /**
458
484
            * @event resume
500
526
                customAttr = Y.Anim.behaviors,
501
527
                easing = attr.easing,
502
528
                lastFrame = d,
 
529
                done = false,
503
530
                attribute,
504
531
                setter,
505
532
                i;
506
533
 
 
534
            if (t >= d) {
 
535
                done = true;
 
536
            }
 
537
 
507
538
            if (reverse) {
508
539
                t = d - t;
509
540
                lastFrame = 0;
515
546
                    setter = (i in customAttr && 'set' in customAttr[i]) ?
516
547
                            customAttr[i].set : Y.Anim.DEFAULT_SETTER;
517
548
 
518
 
                    if (t < d) {
 
549
                    if (!done) {
519
550
                        setter(this, i, attribute.from, attribute.to, t, d, easing, attribute.unit); 
520
551
                    } else {
521
552
                        setter(this, i, attribute.from, attribute.to, lastFrame, d, easing, attribute.unit); 
621
652
            }
622
653
 
623
654
            return val;
 
655
        },
 
656
 
 
657
        destructor: function() {
 
658
            delete Y.Anim._instances[Y.stamp(this)];
624
659
        }
625
660
    };
626
661
 
627
662
    Y.extend(Y.Anim, Y.Base, proto);
628
663
 
629
664
 
630
 
}, '3.1.2' ,{requires:['base-base', 'node-style']});
 
665
}, '3.2.0' ,{requires:['base-base', 'node-style']});