Simple status box for the sidebar.
[elgg_plugins.git] / yui / docs / Scroll.js.html
blobb727c16756695db86ace4d53d52732d6a638fa2a
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <title>API: animation Scroll.js (YUI Library)</title>
5 <link rel="stylesheet" type="text/css" href="assets/api.css">
6 </head>
8 <body id="yahoo-com">
9 <div id="doc3" class="yui-t2">
11 <div id="hd">
12 <h1>Yahoo! UI Library</h1>
13 <h3>animation&nbsp; <span class="subtitle">2.2.0</span></h3>
14 <p>
15 <a href="./index.html">Yahoo! UI Library</a>
16 &gt; <a href="./module_animation.html">animation</a>
18 &gt; Scroll.js (source view)
19 </p>
20 </div>
22 <div id="bd">
23 <div id="yui-main">
24 <div class="yui-b">
26 <div id="srcout">
27 <div class="highlight" ><pre><span class="o">(</span><span class="k">function</span><span class="o">()</span> <span class="o">{</span>
28 <span class="c">/**</span>
29 <span class="c"> * Anim subclass for scrolling elements to a position defined by the &quot;scroll&quot;</span>
30 <span class="c"> * member of &quot;attributes&quot;. All &quot;scroll&quot; members are arrays with x, y scroll positions.</span>
31 <span class="c"> * &lt;p&gt;Usage: &lt;code&gt;var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);&lt;/code&gt;&lt;/p&gt;</span>
32 <span class="c"> * @class Scroll</span>
33 <span class="c"> * @namespace YAHOO.util</span>
34 <span class="c"> * @requires YAHOO.util.Anim</span>
35 <span class="c"> * @requires YAHOO.util.AnimMgr</span>
36 <span class="c"> * @requires YAHOO.util.Easing</span>
37 <span class="c"> * @requires YAHOO.util.Bezier</span>
38 <span class="c"> * @requires YAHOO.util.Dom</span>
39 <span class="c"> * @requires YAHOO.util.Event</span>
40 <span class="c"> * @requires YAHOO.util.CustomEvent </span>
41 <span class="c"> * @extends YAHOO.util.Anim</span>
42 <span class="c"> * @constructor</span>
43 <span class="c"> * @param {String or HTMLElement} el Reference to the element that will be animated</span>
44 <span class="c"> * @param {Object} attributes The attribute(s) to be animated. </span>
45 <span class="c"> * Each attribute is an object with at minimum a &quot;to&quot; or &quot;by&quot; member defined. </span>
46 <span class="c"> * Additional optional members are &quot;from&quot; (defaults to current value), &quot;units&quot; (defaults to &quot;px&quot;). </span>
47 <span class="c"> * All attribute names use camelCase.</span>
48 <span class="c"> * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based</span>
49 <span class="c"> * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)</span>
50 <span class="c"> */</span>
51 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Scroll</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">el</span><span class="o">,</span> <span class="nx">attributes</span><span class="o">,</span> <span class="nx">duration</span><span class="o">,</span> <span class="nx">method</span><span class="o">)</span> <span class="o">{</span>
52 <span class="k">if</span> <span class="o">(</span><span class="nx">el</span><span class="o">)</span> <span class="o">{</span> <span class="c">// dont break existing subclasses not using YAHOO.extend</span>
53 <span class="c"></span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Scroll</span><span class="o">.</span><span class="nx">superclass</span><span class="o">.</span><span class="nx">constructor</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">el</span><span class="o">,</span> <span class="nx">attributes</span><span class="o">,</span> <span class="nx">duration</span><span class="o">,</span> <span class="nx">method</span><span class="o">);</span>
54 <span class="o">}</span>
55 <span class="o">};</span>
57 <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">extend</span><span class="o">(</span><span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">Scroll</span><span class="o">,</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">.</span><span class="nx">ColorAnim</span><span class="o">);</span>
59 <span class="c">// shorthand</span>
60 <span class="c"></span> <span class="k">var</span> <span class="nx">Y</span> <span class="o">=</span> <span class="nx">YAHOO</span><span class="o">.</span><span class="nx">util</span><span class="o">;</span>
61 <span class="k">var</span> <span class="nx">superclass</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Scroll</span><span class="o">.</span><span class="nx">superclass</span><span class="o">;</span>
62 <span class="k">var</span> <span class="nx">proto</span> <span class="o">=</span> <span class="nx">Y</span><span class="o">.</span><span class="nx">Scroll</span><span class="o">.</span><span class="nx">prototype</span><span class="o">;</span>
64 <span class="nx">proto</span><span class="o">.</span><span class="nx">toString</span> <span class="o">=</span> <span class="k">function</span><span class="o">()</span> <span class="o">{</span>
65 <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getEl</span><span class="o">();</span>
66 <span class="k">var</span> <span class="nx">id</span> <span class="o">=</span> <span class="nx">el</span><span class="o">.</span><span class="nx">id</span> <span class="o">||</span> <span class="nx">el</span><span class="o">.</span><span class="nx">tagName</span><span class="o">;</span>
67 <span class="k">return</span> <span class="o">(</span><span class="s2">&quot;Scroll &quot;</span> <span class="o">+</span> <span class="nx">id</span><span class="o">);</span>
68 <span class="o">};</span>
70 <span class="nx">proto</span><span class="o">.</span><span class="nx">doMethod</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">attr</span><span class="o">,</span> <span class="nx">start</span><span class="o">,</span> <span class="nx">end</span><span class="o">)</span> <span class="o">{</span>
71 <span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
73 <span class="k">if</span> <span class="o">(</span><span class="nx">attr</span> <span class="o">==</span> <span class="s1">&#39;scroll&#39;</span><span class="o">)</span> <span class="o">{</span>
74 <span class="nx">val</span> <span class="o">=</span> <span class="o">[</span>
75 <span class="k">this</span><span class="o">.</span><span class="nx">method</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">currentFrame</span><span class="o">,</span> <span class="nx">start</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="nx">end</span><span class="o">[</span><span class="m">0</span><span class="o">]</span> <span class="o">-</span> <span class="nx">start</span><span class="o">[</span><span class="m">0</span><span class="o">],</span> <span class="k">this</span><span class="o">.</span><span class="nx">totalFrames</span><span class="o">),</span>
76 <span class="k">this</span><span class="o">.</span><span class="nx">method</span><span class="o">(</span><span class="k">this</span><span class="o">.</span><span class="nx">currentFrame</span><span class="o">,</span> <span class="nx">start</span><span class="o">[</span><span class="m">1</span><span class="o">],</span> <span class="nx">end</span><span class="o">[</span><span class="m">1</span><span class="o">]</span> <span class="o">-</span> <span class="nx">start</span><span class="o">[</span><span class="m">1</span><span class="o">],</span> <span class="k">this</span><span class="o">.</span><span class="nx">totalFrames</span><span class="o">)</span>
77 <span class="o">];</span>
79 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
80 <span class="nx">val</span> <span class="o">=</span> <span class="nx">superclass</span><span class="o">.</span><span class="nx">doMethod</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">attr</span><span class="o">,</span> <span class="nx">start</span><span class="o">,</span> <span class="nx">end</span><span class="o">);</span>
81 <span class="o">}</span>
82 <span class="k">return</span> <span class="nx">val</span><span class="o">;</span>
83 <span class="o">};</span>
85 <span class="nx">proto</span><span class="o">.</span><span class="nx">getAttribute</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">attr</span><span class="o">)</span> <span class="o">{</span>
86 <span class="k">var</span> <span class="nx">val</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span>
87 <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getEl</span><span class="o">();</span>
89 <span class="k">if</span> <span class="o">(</span><span class="nx">attr</span> <span class="o">==</span> <span class="s1">&#39;scroll&#39;</span><span class="o">)</span> <span class="o">{</span>
90 <span class="nx">val</span> <span class="o">=</span> <span class="o">[</span> <span class="nx">el</span><span class="o">.</span><span class="nx">scrollLeft</span><span class="o">,</span> <span class="nx">el</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">];</span>
91 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
92 <span class="nx">val</span> <span class="o">=</span> <span class="nx">superclass</span><span class="o">.</span><span class="nx">getAttribute</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">attr</span><span class="o">);</span>
93 <span class="o">}</span>
95 <span class="k">return</span> <span class="nx">val</span><span class="o">;</span>
96 <span class="o">};</span>
98 <span class="nx">proto</span><span class="o">.</span><span class="nx">setAttribute</span> <span class="o">=</span> <span class="k">function</span><span class="o">(</span><span class="nx">attr</span><span class="o">,</span> <span class="nx">val</span><span class="o">,</span> <span class="nx">unit</span><span class="o">)</span> <span class="o">{</span>
99 <span class="k">var</span> <span class="nx">el</span> <span class="o">=</span> <span class="k">this</span><span class="o">.</span><span class="nx">getEl</span><span class="o">();</span>
101 <span class="k">if</span> <span class="o">(</span><span class="nx">attr</span> <span class="o">==</span> <span class="s1">&#39;scroll&#39;</span><span class="o">)</span> <span class="o">{</span>
102 <span class="nx">el</span><span class="o">.</span><span class="nx">scrollLeft</span> <span class="o">=</span> <span class="nx">val</span><span class="o">[</span><span class="m">0</span><span class="o">];</span>
103 <span class="nx">el</span><span class="o">.</span><span class="nx">scrollTop</span> <span class="o">=</span> <span class="nx">val</span><span class="o">[</span><span class="m">1</span><span class="o">];</span>
104 <span class="o">}</span> <span class="k">else</span> <span class="o">{</span>
105 <span class="nx">superclass</span><span class="o">.</span><span class="nx">setAttribute</span><span class="o">.</span><span class="nx">call</span><span class="o">(</span><span class="k">this</span><span class="o">,</span> <span class="nx">attr</span><span class="o">,</span> <span class="nx">val</span><span class="o">,</span> <span class="nx">unit</span><span class="o">);</span>
106 <span class="o">}</span>
107 <span class="o">};</span>
108 <span class="o">})();</span>
109 </pre></div>
110 </div>
111 </div>
112 </div>
113 <div class="yui-b">
114 <div class="nav">
116 <div class="module">
117 <h4>Modules</h4>
118 <ul class="content">
120 <li class="selected"><a href="module_animation.html">animation</a></li>
122 <li class=""><a href="module_autocomplete.html">autocomplete</a></li>
124 <li class=""><a href="module_button.html">button</a></li>
126 <li class=""><a href="module_calendar.html">calendar</a></li>
128 <li class=""><a href="module_connection.html">connection</a></li>
130 <li class=""><a href="module_container.html">container</a></li>
132 <li class=""><a href="module_datasource.html">datasource</a></li>
134 <li class=""><a href="module_datatable.html">datatable</a></li>
136 <li class=""><a href="module_dom.html">dom</a></li>
138 <li class=""><a href="module_dragdrop.html">dragdrop</a></li>
140 <li class=""><a href="module_element.html">element</a></li>
142 <li class=""><a href="module_event.html">event</a></li>
144 <li class=""><a href="module_history.html">history</a></li>
146 <li class=""><a href="module_logger.html">logger</a></li>
148 <li class=""><a href="module_menu.html">menu</a></li>
150 <li class=""><a href="module_slider.html">slider</a></li>
152 <li class=""><a href="module_tabview.html">tabview</a></li>
154 <li class=""><a href="module_treeview.html">treeview</a></li>
156 <li class=""><a href="module_yahoo.html">yahoo</a></li>
157 </ul>
158 </div>
160 <div class="module">
161 <h4>Classes</h4>
162 <ul class="content">
163 <li class=""><a href="YAHOO.util.Anim.html">YAHOO.util.Anim</a></li>
164 <li class=""><a href="YAHOO.util.AnimMgr.html">YAHOO.util.AnimMgr</a></li>
165 <li class=""><a href="YAHOO.util.Bezier.html">YAHOO.util.Bezier</a></li>
166 <li class=""><a href="YAHOO.util.ColorAnim.html">YAHOO.util.ColorAnim</a></li>
167 <li class=""><a href="YAHOO.util.Easing.html">YAHOO.util.Easing</a></li>
168 <li class=""><a href="YAHOO.util.Motion.html">YAHOO.util.Motion</a></li>
169 <li class=""><a href="YAHOO.util.Scroll.html">YAHOO.util.Scroll</a></li>
170 </ul>
171 </div>
173 <div class="module">
174 <h4>Files</h4>
175 <ul class="content">
176 <li class=""><a href="Anim.js.html">Anim.js</a></li>
177 <li class=""><a href="AnimMgr.js.html">AnimMgr.js</a></li>
178 <li class=""><a href="Bezier.js.html">Bezier.js</a></li>
179 <li class=""><a href="ColorAnim.js.html">ColorAnim.js</a></li>
180 <li class=""><a href="Easing.js.html">Easing.js</a></li>
181 <li class=""><a href="Motion.js.html">Motion.js</a></li>
182 <li class="selected"><a href="Scroll.js.html">Scroll.js</a></li>
183 </ul>
184 </div>
190 </div>
191 </div>
192 </div>
193 <div id="ft">
194 <hr />
195 Copyright &copy; 2007 Yahoo! Inc. All rights reserved.
196 </div>
197 </div>
198 </body>
199 </html>