Merge branch 'MDL-32509' of git://github.com/danpoltawski/moodle
[moodle.git] / lib / yui / 3.5.0 / build / anim-scroll / anim-scroll.js
blobb0d8d042a2e1a1b97d3c15f009651ee77f354eab
1 /*
2 YUI 3.5.0 (build 5089)
3 Copyright 2012 Yahoo! Inc. All rights reserved.
4 Licensed under the BSD License.
5 http://yuilibrary.com/license/
6 */
7 YUI.add('anim-scroll', function(Y) {
9 /**
10  * Adds support for the <code>scroll</code> property in <code>to</code>
11  * and <code>from</code> attributes.
12  * @module anim
13  * @submodule anim-scroll
14  */
16 var NUM = Number;
18 //TODO: deprecate for scrollTop/Left properties?
19 Y.Anim.behaviors.scroll = {
20     set: function(anim, att, from, to, elapsed, duration, fn) {
21         var
22             node = anim._node, 
23             val = ([
24             fn(elapsed, NUM(from[0]), NUM(to[0]) - NUM(from[0]), duration),
25             fn(elapsed, NUM(from[1]), NUM(to[1]) - NUM(from[1]), duration)
26         ]);
28         if (val[0]) {
29             node.set('scrollLeft', val[0]);
30         }
32         if (val[1]) {
33             node.set('scrollTop', val[1]);
34         }
35     },
36     get: function(anim) {
37         var node = anim._node;
38         return [node.get('scrollLeft'), node.get('scrollTop')];
39     }
44 }, '3.5.0' ,{requires:['anim-base']});