Line | |
---|
1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | /** |
---|
8 | * @class Ext.Element |
---|
9 | */ |
---|
10 | Ext.Element.addMethods({ |
---|
11 | /** |
---|
12 | * Returns true if this element is scrollable. |
---|
13 | * @return {Boolean} |
---|
14 | */ |
---|
15 | isScrollable : function(){ |
---|
16 | var dom = this.dom; |
---|
17 | return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth; |
---|
18 | }, |
---|
19 | |
---|
20 | /** |
---|
21 | * Scrolls this element the specified scroll point. It does NOT do bounds checking so if you scroll to a weird value it will try to do it. For auto bounds checking, use scroll(). |
---|
22 | * @param {String} side Either "left" for scrollLeft values or "top" for scrollTop values. |
---|
23 | * @param {Number} value The new scroll value. |
---|
24 | * @return {Element} this |
---|
25 | */ |
---|
26 | scrollTo : function(side, value){ |
---|
27 | this.dom["scroll" + (/top/i.test(side) ? "Top" : "Left")] = value; |
---|
28 | return this; |
---|
29 | }, |
---|
30 | |
---|
31 | /** |
---|
32 | * Returns the current scroll position of the element. |
---|
33 | * @return {Object} An object containing the scroll position in the format {left: (scrollLeft), top: (scrollTop)} |
---|
34 | */ |
---|
35 | getScroll : function(){ |
---|
36 | var d = this.dom, |
---|
37 | doc = document, |
---|
38 | body = doc.body, |
---|
39 | docElement = doc.documentElement, |
---|
40 | l, |
---|
41 | t, |
---|
42 | ret; |
---|
43 | |
---|
44 | if(d == doc || d == body){ |
---|
45 | if(Ext.isIE && Ext.isStrict){ |
---|
46 | l = docElement.scrollLeft; |
---|
47 | t = docElement.scrollTop; |
---|
48 | }else{ |
---|
49 | l = window.pageXOffset; |
---|
50 | t = window.pageYOffset; |
---|
51 | } |
---|
52 | ret = {left: l || (body ? body.scrollLeft : 0), top: t || (body ? body.scrollTop : 0)}; |
---|
53 | }else{ |
---|
54 | ret = {left: d.scrollLeft, top: d.scrollTop}; |
---|
55 | } |
---|
56 | return ret; |
---|
57 | } |
---|
58 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.