Scrollbar
A jQuery plugin for custom scrollbars.
Demo
Demos are largely unstyled to give developers a better idea of how the plugin can drop into a new or existing project.
<div class="scrollbar">
	...
</div>
$(".scrollbar").scrollbar();
Using Scrollbar
Main
scrollbar.js
scrollbar.css
Dependencies
jQuery
core.js
touch.js
Basic
Scrollbar will allow you to customize the visible scrollbar on overflow content.
$(".target").scrollbar();
<div class="target">
<p>...</p>
</div>
Horizontal
$(".target").scrollbar({
horizontal: true
});
Options
Set instance options by passing a valid object at initialization, or to the public defaults
method. Custom options for a specific instance can also be set by attaching a data-scrollbar-options
attribute to the target elment. This attribute should contain the properly formatted JSON object representing the custom options.
Name | Type | Default | Description |
---|---|---|---|
customClass |
string |
'' |
Class applied to instance |
duration |
int |
0 |
Scroll animation length |
handleSize |
int |
0 |
Handle size; 0 to auto size |
horizontal |
boolean |
false |
Scroll horizontally |
mouseWheel |
boolean |
true |
Flag to prevent scrolling of parent element |
theme |
string |
"fs-light" |
Theme class name |
trackMargin |
int |
0 |
Methods
Methods are publicly available to all active instances, unless otherwise stated.
defaults
Extends plugin default settings; effects instances created hereafter.
$.scrollbar("defaults", { ... });
Parameters
Name | Type | Default | Description |
---|---|---|---|
options |
object |
{} |
New plugin defaults |
destroy
Removes plugin instance.
$(".target").scrollbar("destroy");
resize
Resizes layout on instance of plugin
$(".target").scrollbar("resize");
scroll
Scrolls instance of plugin to element or position
$(".target").scrollbar("scroll", position, duration);
Parameters
Name | Type | Default | Description |
---|---|---|---|
position |
string or int |
null |
Target element selector or static position |
duration |
int |
null |
Optional scroll duration |
CSS
Class | Type | Description |
---|---|---|
.fs-scrollbar-element |
element |
Target elmement |
.fs-scrollbar |
element |
Base widget class |
.fs-scrollbar.fs-scrollbar-horizontal |
modifier |
Indicates horizontal scrolling |
.fs-scrollbar.fs-scrollbar-setup |
modifier |
Indicates setup state |
.fs-scrollbar.fs-scrollbar-active |
modifier |
Indicates active state |
.fs-scrollbar-content |
element |
Scrolling content |
.fs-scrollbar-bar |
element |
Scrollbar container |
.fs-scrollbar-track |
element |
Scrollbar track container |
.fs-scrollbar-handle |
element |
Scrollbar handle |