jQuery Scrolite Plugin

This plugin appends a vertical scrollbar to any element which you need to limit its dimensions like an image, a div or an ul list etc. This is the initial release of this plugin, so feel free to test it and give me some feedback so I can update this plugin with new improvements or with bug free versions. (horizontal scrollbar will be added later.)

It uses Brandon Aaron’s beautiful mousewheel plugin for mouse wheel scrolling support.

It can be configured with many ways as scrollbar width, color, edge radius, scrollbar bed width, color, edge radius, scroll panel width, scroll panel height, mouse scroll sensitivity.

File sizes are 7.36 kBytes for the development version, 4.08 kBytes for the minified version (as for alpha stage), and 206 bytes for the CSS file. (The zip file is big because of the included jQuery library and png image.)

Demo

You can see a working example here

Download

You can download the package here (Demo page included):

Installation

Include these lines into your script’s <head> declaration:

<script src="lib/jquery.min.js" type="text/javascript"></script><script src="lib/jquery.scrolite.min.js" type="text/javascript"></script><script src="lib/jquery.mousewheel.js" type="text/javascript"></script>

Usage

Then use this script with :

$(".scrollable").scrolite({
width:500,
height:300
});

It will create something like this:

Options

The plugin options are:

'barColor' : The color of the scrollbar handle
'bedColor' : The color of the scrollbar bed
'bedWidth' : Width of the scrollbar bed
'bedCornerRadius' : CSS3 border-radius of scrollbar bed
'barWidth' : Scrollbar handle width
'barCornerRadius' : CSS3 border-radius of scrollbar handle
'width' : scrollable area width
'height' : scrollable area height
'scrollSensitivity' : pixel scrolling value of one tick of the mousewheel
'bedMarginTop' : pixel margin for top of the scroller bed
'bedMarginBottom' : pixel margin for bottom of the scroller bed
'bedMarginLeft' : pixel margin for left of the scroller bed
'bedMarginRight' : pixel margin for right of the scroller bed

CSS Elements

You can change other CSS values by referring to these classes in your styles file:

'.scrolite' : refers to container of all the elements below
'.scrolite-bed' : refers to scrollbar bed element
'.scrolite-bar' : refers to scrollbar handle element
'.scrolite-container' : refers to the scrollable area wrapper

Public Functions

If you are using an AJAX script to load it’s contents from somewhere, you can refresh the scrollbar’s calculations by this function (included in the demo file):

$(".scrollable").data("scrolite").refresh()

The “.scrollable” refers to your initial element which you’ve added the scrollbar.

 

3 comments

  1. Hi,
    I know all scroll plugins at internet. Your job is the best.
    I tried to use it at responsive grid systems but I couldn’t succeed to refresh the resize scrollable ares when resize window.
    I hope you give us a solution.
    Many thanks.
    Best regards.

Leave a Reply

Your email address will not be published. Required fields are marked *