jQuery Based Custom Scrollbar Ver. 1.0

Download

This is a jQuery based custom scrollbar plugin designed to give the website designer the ability to override the OS's generic scrollbar, using their own customized scrollbar.

It requires no knowledge of Javascript/jQuery, and can be fully implemented using only HTML & CSS, using a few custom classes and attributes.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque vel ante libero, eu luctus ligula. Integer aliquet diam eget felis sollicitudin eget iaculis nulla tincidunt. Ut ornare nisi nec ipsum euismod eu auctor magna mattis. Morbi tempus mattis massa, non tempor tellus porta consectetur. Suspendisse ut sagittis libero. Donec vel odio odio, vel convallis leo. Ut congue ultricies porttitor.

Suspendisse potenti. Suspendisse quis felis tortor, ullamcorper tristique lacus. Nunc auctor tempus metus et accumsan. Suspendisse condimentum dapibus felis, ac pulvinar elit viverra id. Curabitur in leo in nisl lacinia blandit vel nec ipsum. Vivamus id gravida purus. Fusce lobortis iaculis ultrices. Donec iaculis congue gravida. Quisque lectus turpis, luctus vel tristique eget, venenatis sed turpis. Cras ac nunc vel enim venenatis lacinia. Suspendisse pharetra sodales quam sit amet interdum. Nam vel mauris lectus. In nec sem quis augue posuere dignissim. Curabitur id risus vitae lectus consequat dapibus. Etiam facilisis rutrum orci, sit amet suscipit purus posuere sit amet. Quisque ac aliquet arcu

Vestibulum ac ante tellus, facilisis congue enim. Sed fermentum suscipit turpis, vitae bibendum quam dignissim non. Nam consequat commodo nunc ut scelerisque. Maecenas vestibulum molestie nunc id mollis. Aenean a massa id diam dapibus congue in eget nisl. Fusce et lectus enim, eget vulputate mi. Nam fermentum elit sit amet elit tincidunt sagittis.

Mauris id tempor nunc. Nunc lacinia tincidunt quam sit amet convallis. Praesent dignissim dictum viverra. Suspendisse commodo diam sed lacus rutrum eget pharetra felis vestibulum. Suspendisse eu mi ligula. Suspendisse semper, velit a commodo rhoncus, dui nisl dapibus nunc, sed hendrerit dui tortor vitae urna. Maecenas nec lacus ac lorem ultricies porta. Donec libero ante, malesuada vel mollis non, dapibus nec enim. Maecenas luctus dignissim augue sit amet aliquet. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum auctor nulla augue. Fusce tempor mi sed nunc fringilla tincidunt.

Ut semper sapien eu augue viverra rhoncus. Nam quis justo purus. Praesent porttitor, metus eu aliquet mollis, metus libero sodales dolor, a tincidunt lectus nisi sed lorem. Suspendisse potenti. Mauris tincidunt dignissim ipsum, quis dictum nibh interdum malesuada. Phasellus vitae ultrices urna. Nullam eget nisl dui. Cras eget urna eu tellus sollicitudin posuere et tincidunt arcu. Sed sem turpis, sodales in cursus at, auctor at dolor. Praesent rhoncus leo eu massa laoreet venenatis. Maecenas in porttitor elit. Phasellus tristique hendrerit eros, ac egestas neque eleifend id. Nunc laoreet volutpat orci sed fringilla.

Etiam accumsan hendrerit libero quis convallis. Cras eu augue velit, et tempor lectus. Mauris ultrices mattis velit id tempor. Integer felis diam, ornare eu pretium nec, dignissim sit amet sem. Suspendisse blandit scelerisque adipiscing. Sed molestie nibh et nisl aliquam ut ullamcorper purus gravida. Nullam semper ullamcorper orci et convallis. Nunc volutpat malesuada faucibus.

Nulla consequat posuere quam, a ullamcorper lectus dapibus eget. Praesent ultrices, lectus quis egestas dapibus, est elit pharetra ligula, ut tincidunt tortor arcu eu mi. Vestibulum feugiat imperdiet iaculis. In turpis eros, condimentum sed interdum eget, mattis a enim. Maecenas adipiscing ultricies elit quis tempor. Donec eu felis non dui venenatis scelerisque. Fusce leo tellus, pretium vehicula cursus id, suscipit nec nunc. Proin non risus sed tortor sodales sollicitudin.

Aliquam id arcu purus. Nullam pellentesque lobortis justo id semper. Sed sapien ipsum, feugiat vel suscipit sed, tincidunt quis metus. Curabitur hendrerit tristique risus pellentesque facilisis. Fusce adipiscing pharetra fringilla. Suspendisse iaculis eros et mi sollicitudin in fermentum quam ornare. Aenean eu accumsan dui. Curabitur posuere pellentesque libero id scelerisque. Fusce fringilla iaculis elementum


Requirements

For this plugin to work, both the jQuery & jQuery UI libraries are required. However, it is recommended that the Google hosted versions are used. This can be done by adding the following two elements to the head of the document:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script
type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.js"></script>

Use

Below is an example implementation. Each of the highlighted blocks of code are required for the plugin to work properly. Mouse over each block for more information on it. It is left up to you to style and position the content, scrollbar, & slider.

<head>
    <script type="text/javascript">
    $(document).ready(function(){
        initScrollbars();
    });
</script>

</head>
<body>
    ...
    <div id="example1_area" class="_scrollarea" _scroll_attachedBar="example1_bar">
        ... Scroll Area content goes here ...
    </div>
    <div id="example1_bar" class="_scrollbar" _scroll_attachedArea="example1_area">
        <span id="example1_slider" class="_scrollbar_slider"></span>
    </div>
    ...
</body>
Makes the browser tell the plugin when all the elements on the page have been loaded, at which point the plugin kicks in and initializes all the scrollbars. This is needed only once per page.
A unique id name to identify the element containing the content that needs to be scrolled.
The special class _scrollarea tells the plugin that this element contains content that is to be scrolled using the custom scrollbar.
The attribute _scroll_attachedBar is used to associate the scrollbar to the content. This attribute must contain the unique id of the associated scrollbar.
A unique id name to identify the scrollbar element.
The special class _scrollbar tells the plugin that this element is to be the scrollbar for the associated content.
The attribute _scroll_attachedArea is used to associate the content to the scrollbar. This attribute must contain the unique id of the associated content element.
The special class _scrollbar_slider tells the plugin that this element is the slider for its parent scrollbar element


Disclaimer

This plugin is provided as-is, with absolutely no warranty or support. Any risk in using this code is borne entirely by the user. Jack Gettings is not responsible for any loss or damage caused by the use of this software.