3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.com/license
18 Ext.Element.addMethods({
19 <div id="method-Ext.Element-scrollTo"></div>/**
20 * 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().
21 * @param {String} side Either "left" for scrollLeft values or "top" for scrollTop values.
22 * @param {Number} value The new scroll value
23 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
24 * @return {Element} this
26 scrollTo : function(side, value, animate) {
27 //check if we're scrolling top or left
28 var top = /top/i.test(side),
32 if (!animate || !me.anim) {
33 // just setting the value, so grab the direction
34 prop = 'scroll' + (top ? 'Top' : 'Left');
38 // if scrolling top, we need to grab scrollLeft, if left, scrollTop
39 prop = 'scroll' + (top ? 'Left' : 'Top');
40 me.anim({scroll: {to: top ? [dom[prop], value] : [value, dom[prop]]}}, me.preanim(arguments, 2), 'scroll');
45 <div id="method-Ext.Element-scrollIntoView"></div>/**
46 * Scrolls this element into view within the passed container.
47 * @param {Mixed} container (optional) The container element to scroll (defaults to document.body). Should be a
48 * string (id), dom node, or Ext.Element.
49 * @param {Boolean} hscroll (optional) False to disable horizontal scroll (defaults to true)
50 * @return {Ext.Element} this
52 scrollIntoView : function(container, hscroll) {
53 var c = Ext.getDom(container) || Ext.getBody().dom,
55 o = this.getOffsetsTo(c),
56 l = o[0] + c.scrollLeft,
57 t = o[1] + c.scrollTop,
58 b = t + el.offsetHeight,
59 r = l + el.offsetWidth,
61 ct = parseInt(c.scrollTop, 10),
62 cl = parseInt(c.scrollLeft, 10),
64 cr = cl + c.clientWidth;
66 if (el.offsetHeight > ch || t < ct) {
72 // corrects IE, other browsers will ignore
73 c.scrollTop = c.scrollTop;
75 if (hscroll !== false) {
76 if (el.offsetWidth > c.clientWidth || l < cl) {
80 c.scrollLeft = r - c.clientWidth;
82 c.scrollLeft = c.scrollLeft;
88 scrollChildIntoView : function(child, hscroll) {
89 Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
92 <div id="method-Ext.Element-scroll"></div>/**
93 * Scrolls this element the specified direction. Does bounds checking to make sure the scroll is
94 * within this element's scrollable range.
95 * @param {String} direction Possible values are: "l" (or "left"), "r" (or "right"), "t" (or "top", or "up"), "b" (or "bottom", or "down").
96 * @param {Number} distance How far to scroll the element in pixels
97 * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
98 * @return {Boolean} Returns true if a scroll was triggered or false if the element
99 * was scrolled as far as it could go.
101 scroll : function(direction, distance, animate) {
102 if (!this.isScrollable()) {
106 l = el.scrollLeft, t = el.scrollTop,
107 w = el.scrollWidth, h = el.scrollHeight,
108 cw = el.clientWidth, ch = el.clientHeight,
111 l: Math.min(l + distance, w-cw),
112 r: v = Math.max(l - distance, 0),
113 t: Math.max(t - distance, 0),
114 b: Math.min(t + distance, h-ch)
119 direction = direction.substr(0, 1);
120 if ((v = hash[direction]) > -1) {
122 this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.preanim(arguments, 2));