[Jifty-commit] r1411 - in jifty/trunk: share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Jun 30 02:17:47 EDT 2006
Author: trs
Date: Fri Jun 30 02:17:46 2006
New Revision: 1411
Added:
jifty/trunk/share/web/static/js/jifty_smoothscroll.js
Modified:
jifty/trunk/ (props changed)
Log:
r13597 at zot: tom | 2006-06-30 02:17:28 -0400
Oops. This is kinda needed for the smooth scrolling to work. ;)
Added: jifty/trunk/share/web/static/js/jifty_smoothscroll.js
==============================================================================
--- (empty file)
+++ jifty/trunk/share/web/static/js/jifty_smoothscroll.js Fri Jun 30 02:17:46 2006
@@ -0,0 +1,36 @@
+
+if (typeof Jifty == "undefined") Jifty = { };
+
+Jifty.SmoothScroll = {
+ interval: '',
+ steps: 20,
+
+ scrollTo: function( y ) {
+ if ( Jifty.SmoothScroll.interval )
+ clearInterval( Jifty.SmoothScroll.interval );
+
+ var stepsize = parseInt( ( y - Jifty.Utils.getScrollTop() ) / Jifty.SmoothScroll.steps );
+
+ Jifty.SmoothScroll.interval
+ = setInterval('Jifty.SmoothScroll.scrollWindow('+stepsize+','+y+')',10);
+ },
+
+ scrollWindow: function( amount, y ) {
+ var curpos = Jifty.Utils.getScrollTop();
+ var isAbove = ( curpos < y );
+
+ window.scrollTo( 0, curpos + amount );
+
+ var newpos = Jifty.Utils.getScrollTop();
+ var newIsAbove = ( newpos < y );
+
+ if ( ( isAbove != newIsAbove ) || ( curpos == newpos ) ) {
+ /* We've just scrolled past the destination, or we haven't moved
+ from the last scroll (i.e., we're at the bottom of the page),
+ so scroll exactly to the position
+ */
+ window.scrollTo( 0, y );
+ clearInterval( Jifty.SmoothScroll.interval );
+ }
+ }
+};
More information about the Jifty-commit
mailing list