webgui/www/extras/yui/docs/animation/overview-summary-Scroll.js.html
JT Smith 4f68a0933c added YUI and YUI-ext
fixed the resizable text area with IE problem
fixed the ad space with IE problem
merged the 7.2.0 and 7.1.4 change logs
2006-11-07 23:15:57 +00:00

300 lines
8.8 KiB
HTML

<html>
<head>
<title>
JavaScript Documentation -
Scroll.js
</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header">
<h1>JavaScript Documentation</h1>
<h3><a href="./index.html">Animation Utility</a></h3>
<div class="breadcrumbs">
<a href="javascript: alert('This location is TBD');">Home</a>
&gt;
<a href="./index.html">Animation Utility</a>
&gt;
<strong>Scroll.js</strong>
</div>
</div>
<div id="body">
<div class="nav">
<div class="module resources">
<ul class="content">
<li><a href="overview-tree.html">Tree View</a></li>
<li><a href="index-all.html">Element Index</a></li>
</ul>
</div>
<div class="module">
<h4><a href="./allclasses-noframe.html">Classes</a></h4>
<ul class="content">
<li>
<a href="YAHOO.util.html">
YAHOO.util</a>
</li>
<li>
<a href="YAHOO.util.Anim.html">
YAHOO.util.Anim</a>
</li>
<li>
<a href="YAHOO.util.AnimMgr.html">
YAHOO.util.AnimMgr</a>
</li>
<li>
<a href="YAHOO.util.Bezier.html">
YAHOO.util.Bezier</a>
</li>
</ul>
</div>
<div class="module">
<h4><a href="./overview-summary.html">Files</a></h4>
<ul class="content">
<li>
<a href="overview-summary-Anim.js.html">
Anim.js</a>
</li>
<li>
<a href="overview-summary-AnimMgr.js.html">
AnimMgr.js</a>
</li>
<li>
<a href="overview-summary-Bezier.js.html">
Bezier.js</a>
</li>
<li>
<a href="overview-summary-ColorAnim.js.html">
ColorAnim.js</a>
</li>
<li>
<a href="overview-summary-Easing.js.html">
Easing.js</a>
</li>
<li>
<a href="overview-summary-Motion.js.html">
Motion.js</a>
</li>
<li>
<a href="overview-summary-Scroll.js.html">
Scroll.js</a>
</li>
</ul>
</div>
</div>
<div class="main">
<h2>Scroll.js</h2>
<div class="meta">
</div>
<div class="section source">
<h3><a name="source">Souce Code</a> <span class="top">[<a href="#top">top</a>]</span></h3>
<pre class="sourceview"><span class="comment">/*
Copyright (c) 2006, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
Version: 0.10.0
*/</span>
<span class="comment">/**
* <span class="attrib">@class</span> Anim subclass for scrolling elements to a position defined by the "scroll" member of "attributes". All "scroll" members are arrays with x, y scroll positions.
* &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 class="attrib">@requires</span> YAHOO.util.Anim
* <span class="attrib">@requires</span> YAHOO.util.AnimMgr
* <span class="attrib">@requires</span> YAHOO.util.Easing
* <span class="attrib">@requires</span> YAHOO.util.Bezier
* <span class="attrib">@requires</span> YAHOO.util.Dom
* <span class="attrib">@requires</span> YAHOO.util.Event
* <span class="attrib">@requires</span> YAHOO.util.CustomEvent
* <span class="attrib">@constructor</span>
* <span class="attrib">@param</span> {String or HTMLElement} el Reference to the element that will be animated
* <span class="attrib">@param</span> {Object} attributes The attribute(s) to be animated.
* Each attribute is an object with at minimum a "to" or "by" member defined.
* Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
* All attribute names use camelCase.
* <span class="attrib">@param</span> {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
* <span class="attrib">@param</span> {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>
(<span class="reserved">function</span>() {
YAHOO.util.Scroll = <span class="reserved">function</span>(el, attributes, duration, method) {
<span class="reserved">if</span> (el) { <span class="comment">// dont break existing subclasses not using YAHOO.extend</span>
YAHOO.util.Scroll.superclass.constructor.call(<span class="reserved">this</span>, el, attributes, duration, method);
}
};
YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
<span class="comment">// shorthand</span>
var Y = YAHOO.util;
var superclass = Y.Scroll.superclass;
var <span class="reserved">prototype</span> = Y.Scroll.<span class="reserved">prototype</span>;
<span class="comment">/**
* toString method
* <span class="attrib">@return</span> {String} string represenation of anim obj
*/</span>
<span class="reserved">prototype</span>.toString = <span class="reserved">function</span>() {
var el = <span class="reserved">this</span>.getEl();
var id = el.id || el.tagName;
<span class="reserved">return</span> (<span class="literal">"Scroll "</span> + id);
};
<span class="comment">/**
* Returns the value computed by the animation's "method".
* <span class="attrib">@param</span> {String} attr The name of the attribute.
* <span class="attrib">@param</span> {Number} start The value this attribute should start from for this animation.
* <span class="attrib">@param</span> {Number} end The value this attribute should end at for this animation.
* <span class="attrib">@return</span> {Number} The Value to be applied to the attribute.
*/</span>
<span class="reserved">prototype</span>.doMethod = <span class="reserved">function</span>(attr, start, end) {
var val = null;
<span class="reserved">if</span> (attr == <span class="literal">'scroll'</span>) {
val = [
<span class="reserved">this</span>.method(<span class="reserved">this</span>.currentFrame, start[0], end[0] - start[0], <span class="reserved">this</span>.totalFrames),
<span class="reserved">this</span>.method(<span class="reserved">this</span>.currentFrame, start[1], end[1] - start[1], <span class="reserved">this</span>.totalFrames)
];
} <span class="reserved">else</span> {
val = superclass.doMethod.call(<span class="reserved">this</span>, attr, start, end);
}
<span class="reserved">return</span> val;
};
<span class="comment">/**
* Returns current value of the attribute.
* <span class="attrib">@param</span> {String} attr The name of the attribute.
* <span class="attrib">@return</span> {Number} val The current value of the attribute.
*/</span>
<span class="reserved">prototype</span>.getAttribute = <span class="reserved">function</span>(attr) {
var val = null;
var el = <span class="reserved">this</span>.getEl();
<span class="reserved">if</span> (attr == <span class="literal">'scroll'</span>) {
val = [ el.scrollLeft, el.scrollTop ];
} <span class="reserved">else</span> {
val = superclass.getAttribute.call(<span class="reserved">this</span>, attr);
}
<span class="reserved">return</span> val;
};
<span class="comment">/**
* Applies a value to an attribute
* <span class="attrib">@param</span> {String} attr The name of the attribute.
* <span class="attrib">@param</span> {Number} val The value to be applied to the attribute.
* <span class="attrib">@param</span> {String} unit The unit ('px', '%', etc.) of the value.
*/</span>
<span class="reserved">prototype</span>.setAttribute = <span class="reserved">function</span>(attr, val, unit) {
var el = <span class="reserved">this</span>.getEl();
<span class="reserved">if</span> (attr == <span class="literal">'scroll'</span>) {
el.scrollLeft = val[0];
el.scrollTop = val[1];
} <span class="reserved">else</span> {
superclass.setAttribute.call(<span class="reserved">this</span>, attr, val, unit);
}
};
})();
</pre>
</div>
</div>
</div>
<div id="footer">
<hr />
Copyright &copy; 2004 - 2005 Yahoo! Inc. All rights reserved.
<br />
Yahoo! Confidential.
<br /><br />
Documentation generated by <a href="http://jsdoc.sourceforge.net/">JSDoc</a>
version 1.9.5.8
</div>
</body>
</html>