jQuery Scroll Follow


Scroll Follow is a simple jQuery plugin that enables a DOM object to follow the page as the user scrolls. Scroll Follow has been successfully tested on IE6, IE7, FF2, FF3, Safari 3, and Opera 9 on Windows. It has been successfully tested on FF3 and Safari 3 on MacOSX.




  1. Include jQuery:
    1. <script type="text/javascript" src="jquery.js"></script>
  2. Include required plugins, including Scroll Follow:
    1. <script type="text/javascript" src="ui.core.js"></script>
    2. <script type="text/javascript" src="jquery.scrollFollow.js"></script>
  3. Call Scroll Follow on the desired DOM object:
    View Example
    1. <script type="text/javascript">
    2.   $( '#example' ).scrollFollow();
    3. </script>
  4. Or call Scroll Follow on the desired DOM object and give it some parameters:
    View Example
    1. <script type="text/javascript">
    2.  $( document ).ready( function () {
    3.    $( '#example' ).scrollFollow( {
    4.     speed: 1000,
    5.     offset: 60,
    6.     killSwitch: 'exampleLink',
    7.     onText: 'Disable Follow',
    8.     offText: 'Enable Follow'
    9.    } );
    10.  } );
    11. </script>
  5. The Scroll Follow object will remain inside its immediate container.
    View Example
  6. Or you can specify a parent (by ID) for the Scroll Follow object to consider its container:
    View Example
    1. <script type="text/javascript">
    2.  $( document ).ready( function () {
    3.   $( '#example' ).scrollFollow( {
    4.    container: 'outer'
    5.   } );
    6.  } );
    7. </script>
  7. Scroll Follow uses the "top" property of an object to slide it. Therefore, the "position" of the object must be set to either "relative" or "absolute." Other than that limitation, the Scroll Follow object should be completely configured through CSS.


• speed
int - default: 500
The duration of the sliding animation (in milliseconds). The smaller the value, the faster the animation.
• easing
string - default: 'linear'
If included, use any one of the easing options from the easing plugin. Uses 'linear' by default which provides no easing.
• offset
int - default: 0
Number of pixels the Scroll Follow object should remain from top of viewport.
• container
string - default: object's immediate parent
ID of the containing div.
• killSwitch
string - default: 'killSwitch'
ID of the On/Off toggle element. Requires the jQuery Cookie plugin.
• onText
string - default: 'Turn Slide Off'
killSwitch text to be displayed if sliding is enabled.
• offText
string - default: 'Turn Slide On'
killSwitch text to be displayed if sliding is disabled.
• relativeTo
string - default: 'top'
Scroll animation can be relative to either the 'top' or 'bottom' of the viewport.
• delay
int - default: 0
Time between the end of the scroll and the beginning of the animation in milliseconds.


• October 29, 2008 - Version 0.4.0
Added 'delay' parameter which sets the scroll follow to only happen a set interval after the last scroll
Added a window.resize listener
Removed the requirement for the easing plugin (still necessary for advanced easing settings)
Removed the requirement for the cookie plugin (still necessary for using a killswitch)
Removed 'animate' parameter. Effect can be fully realized with CSS
Fixed typo in version of ui.core.js tested
• October 22, 2008 - Version 0.3.1
Fixed behavior when 'relativeTo' is set to 'bottom.' Previous behavior allowed the scrolling object to break out of the top of its container.
• October 7, 2008 - Version 0.3.0
Reworked animating logic to take more situations into account.
Added animating to initial position on page load.
Added animating to initial position on reenabling of following.
Added 'relativeTo' parameter: allows the scroll following object to reposition based on the top or the bottom of the viewport.
• July 2, 2008 - Version 0.2.1
Minor bug fix.
• July 2, 2008 - Version 0.2.0
Added 'animate' parameter. Allows a scroll following effect with no animation.
• May 23, 2008 - Version 0.1.0
Initial Release

Site Info

Contact Us

By Phone:
979-696-SITE (7483)
By Email:
Send Email
For Support:
Please visit our Get Satisfaction forum.

About Us

The Kitchen is run by the fine folk at Net Perspective, LLC.

Find out more about The Kitchen or visit us at Net-Perspective.com.


This site, its contents, and its design are © Copyright 2008 - 4186 Net Perspective, LLC. All rights reserved.

Some images used here by permission are copyright of their respective owners. Thanks to Mark James for the fantastic Silk icon set.