John Lindal![]()
This extension to Y.Node overrides scrollIntoView(). The default browser behavior always places the element at the top or bottom of its container. This override is smart enough to not scroll if the element is already visible, and it also provides animation.
In addition, if the body does not have a scrollbar, this override will not scroll the body. The default browser behavior sometimes does, and then there is no way to recover.
Yet another nice feature is the ability to specify a viewport margin, to keep the scrolled element from ending up under another element with position:fixed.
Example of scrolling a node into view.
<script src="http://yui.yahooapis.com/3.5.1/build/yui/yui-min.js"></script>YUI({
//Last Gallery Build of this module
gallery: 'gallery-2013.04.24-22-00'
}).use('gallery-scrollintoview', function(Y)
{
Y.one('#my-button').scrollIntoView();
});
| Subject | Author | Date |
|---|---|---|
| ScrollIntoView doesn't work. | John Mizliso | 06/26/12 |
| Re: ScrollIntoView doesn't work. | John Lindal | 06/27/12 |
| Re: ScrollIntoView doesn't work. | John Mizliso | 06/27/12 |
| Only scrolls to nodes higher up the page | richard g | 09/25/12 |
| Re: Only scrolls to nodes higher up the page | John Lindal | 09/25/12 |
| Re: Only scrolls to nodes higher up the page | richard g | 09/26/12 |
| Smooth scrolling support | richard g | 01/15/13 |
| Re: Smooth scrolling support | John Lindal | 01/15/13 |
| Re: Smooth scrolling support | John Lindal | 04/24/13 |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info