Skroller.js is a jQuery plugin that transforms elements such as div's into scrollable areas with customizable scrollbars that are consistent across different browsers
Simple, just call skroller() method on the jQuery selector and you are pretty much done... Relatively straightforward right?
A little visual example...
Furtum certe punit lex tua, domine, et lex scripta in cordibus hominum, quam ne ipsa quidem delet iniquitas: quis enim fur aequo animo furem patitur? nec copiosus adactum inopia. et ego furtum facere volui, et feci, nulla conpulsus egestate, nisi penuria et fastidio iustitiae et sagina iniquitatis. nam id furatus sum, quod mihi abundabat et multa melius; nec ea re volebam frui, quam furto appetebam, sed ipso furto et peccato. arbor erat pirus in vicinia nostrae vineae, pomis onusta, nec forma nec sapore inlecebrosis. ad hanc excutiendam atque asportandam nequissimi adulescentuli perreximus nocte intempesta, quousque ludum de pestilentiae more in areis produxeramus, et abstulimus inde onera ingentia non ad nostras epulas, sed vel proicienda porcis, etiamsi aliquid inde comedimus, dum tamen fieret a nobis quod eo liberet, quo non liceret. ecce cor meum, deus, ecce cor meum, quod miseratus es in imo abyssi. dicat tibi nunc ecce cor meum, quid ibi quaerebat, ut essem gratis malus et malitiae meae causa nulla esset nisi malitia. foeda erat, et amavi eam; amavi perire, amavi defectum meum, non illud, ad quod deficiebam, sed defectum meum ipsum amavi, turpis anima et dissiliens a firmamento tuo in exterminium, non dedecore aliquid, sed dedecus appetens.
$('#SkrollThis').skroller();
Easy enough, right?
Skroller has a few options that can be passed when the method is called here is a list with their defaults
Option |
Default |
Description |
|---|---|---|
| height | 200 | Defines the fixed height of the rendered scrollable element in pixels |
| maxHeight | false | If set to a number will wrap the scrollable element around the target and expand untill the height in pixel is reached then start scrolling |
| barWidth | 10 | The scrollbar width in pixel |
| barColor | #2C96DE | The color of the scrollbar |
| barOpacity | 1 | The bar opacity from 0 to 1 |
| barMinHeight | 20 | The minimum height of the scrollbar |
| barMaxHeight | =height | The maximum height of the scrollbar |
| barHide | false | Setting this to true will hide the bar and show it when the mouse is over the scrollable element |
| barHideDelay | 0.5 | Value in seconds before the scrollbar fades away when the mouse leaves the scrollable element |
| railOff | false | Setting this to true will NOT render the rail, just the scrollbar |
| railHide | =barHide | Inherit the value of barHide but can be changed to customize the rail behavior separately |
| railColor | =barColor | Set custom color for the rail |
| railOpacity | =barOpacity/5 | Customize the rail opacity from 0 to 1 |
| indent | =barWidth+(barWidth/2) | The distance between the content and the scrollbar |
| padding | 0 | the distance between the content and the frame |
| style | 'smooth' | Can be 'round', 'smooth', 'square' or a numeric value that defines the roundness of the scrollbar corners |
| frameClass | 'skroller' | Defines a custom class for the scrollable element to offer more customization options |
| WheelSpeed | 1 | the number of lines to be scrolled at one time |
Furtum certe punit lex tua, domine, et lex scripta in cordibus hominum, quam ne ipsa quidem delet iniquitas: quis enim fur aequo animo furem patitur? nec copiosus adactum inopia. et ego furtum facere volui, et feci, nulla conpulsus egestate, nisi penuria et fastidio iustitiae et sagina iniquitatis. nam id furatus sum, quod mihi abundabat et multa melius; nec ea re volebam frui, quam furto appetebam, sed ipso furto et peccato. arbor erat pirus in vicinia nostrae vineae, pomis onusta, nec forma nec sapore inlecebrosis. ad hanc excutiendam atque asportandam nequissimi adulescentuli perreximus nocte intempesta, quousque ludum de pestilentiae more in areis produxeramus, et abstulimus inde onera ingentia non ad nostras epulas, sed vel proicienda porcis, etiamsi aliquid inde comedimus, dum tamen fieret a nobis quod eo liberet, quo non liceret. ecce cor meum, deus, ecce cor meum, quod miseratus es in imo abyssi. dicat tibi nunc ecce cor meum, quid ibi quaerebat, ut essem gratis malus et malitiae meae causa nulla esset nisi malitia. foeda erat, et amavi eam; amavi perire, amavi defectum meum, non illud, ad quod deficiebam, sed defectum meum ipsum amavi, turpis anima et dissiliens a firmamento tuo in exterminium, non dedecore aliquid, sed dedecus appetens.
$('#SkrollThis2').skroller({
height : 300,
barWidth : 30,
barOpacity : 0.8,
barMinHeight : 60,
barColor : '#F90',
style : 'round',
padding : 10,
frameClass : 'skrollerCustomClass'
});
The coolest part? You can use it on anything! Even images... and make them scrollable! Hoohoo!
<img id="milo" src="milo.jpg" />
$('#milo').skroller({
height : 300,
barOpacity : 0.5,
barColor : '#FFF',
indent : 0,
style : 'square'
});
Skroller is still a work-in-progress so there might be bugs, compatibility issues and it might pose a threat to your pets... I mainly developed it for personal use on my projects but I like sharing (because it's caring) and I will try and keep it updated... feel free to fork it of course and report any issues you may find.
Also forgive me if my code is not clean / canonical / rational / standardized etc... (you get the point) I am a web designer, self-taught web developer who likes to hack code, so you've been warned! :)