jScrollPane is a jquery plugin which allows you to replace the browsers default vertical scrollbars on any block level element with an overflow:auto style. You can easily control the apperance of the custom scrollbars using simple CSS.
jScrollPane is crossbrowser, working on all browsers that support jquery and it also degrades gracefully. If a user's browser doesn't support jQuery or has JavaScript turned off then they will see the browsers default scrollbars. If the mouse wheel plugin is included in the page then the scroll panes will respond to mouse wheel events as well.
jScrollPane is built on top of the awesome jQuery library and utilises the dimensions plugin and (optionally) the mouse wheel plugin.
There are a number of different examples of different ways you can use jScrollPane:
Just include the following files in the head of your page:
Like so:
<script type="text/javascript" src="jquery-1.1.3.1.pack.js"></script> <script type="text/javascript" src="jquery.dimensions.min.js"></script> <script type="text/javascript" src="jquery.mousewheel.min.js"></script> <script type="text/javascript" src="jScrollPane.min.js"></script> <link rel="stylesheet" type="text/css" media="all" href="jScrollPane.css" />
Then you can use any query selector to select the elements you would like to apply jScrollPane and then initialise it. The following code runs when the document is ready and finds any element with a class of "scroll-pane" and then calls jScrollPane on them.
$(function() { $('.scroll-pane').jScrollPane(); });
You can pass some optional parameters to the jScrollPane function. These take the form of an object with the following attributes:
You can download this plugin in a number of ways. Easiest is the zip file which contains all the files used in these example pages. Alternatively you can download the indivdual files from the links above. jScrollPane is also available in the jQuery svn repository.
Because the element that you turn into a scrollpane is wrapped in another element you can't apply any positional styling to it. This is a shame but the problem is easily avoided by wrapping the element in another div with the positional styling on it (like the divs on this page with a class of holder).
Bug reports and enhancement requests should be made through the jScrollPane plugin page on the jQuery site.
All support requests should be made through the jQuery mailing list.