initial import
[roojs1] / Roo / lib / Scroll.js
1 /*
2  * Portions of this file are based on pieces of Yahoo User Interface Library
3  * Copyright (c) 2007, Yahoo! Inc. All rights reserved.
4  * YUI licensed under the BSD License:
5  * http://developer.yahoo.net/yui/license.txt
6  * <script type="text/javascript">
7  *
8  */
9     (function() {
10         Roo.lib.Scroll = function(el, attributes, duration, method) {
11             if (el) {
12                 Roo.lib.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
13             }
14         };
15
16         Roo.extend(Roo.lib.Scroll, Roo.lib.ColorAnim);
17
18
19         var Y = Roo.lib;
20         var superclass = Y.Scroll.superclass;
21         var proto = Y.Scroll.prototype;
22
23         proto.toString = function() {
24             var el = this.getEl();
25             var id = el.id || el.tagName;
26             return ("Scroll " + id);
27         };
28
29         proto.doMethod = function(attr, start, end) {
30             var val = null;
31
32             if (attr == 'scroll') {
33                 val = [
34                         this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
35                         this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
36                         ];
37
38             } else {
39                 val = superclass.doMethod.call(this, attr, start, end);
40             }
41             return val;
42         };
43
44         proto.getAttribute = function(attr) {
45             var val = null;
46             var el = this.getEl();
47
48             if (attr == 'scroll') {
49                 val = [ el.scrollLeft, el.scrollTop ];
50             } else {
51                 val = superclass.getAttribute.call(this, attr);
52             }
53
54             return val;
55         };
56
57         proto.setAttribute = function(attr, val, unit) {
58             var el = this.getEl();
59
60             if (attr == 'scroll') {
61                 el.scrollLeft = val[0];
62                 el.scrollTop = val[1];
63             } else {
64                 superclass.setAttribute.call(this, attr, val, unit);
65             }
66         };
67     })();