Stanko / rocketScroll

Pure small JavaScript scroll bar script. Support native mouse wheel scroll. Easy customizable css. Works even in IE8+.
32 stars 7 forks source link

rocketScroll

Pure JavaScript scroll bar script. Support native mouse wheel scroll. Easy customizable css. Works even in IE8+.

Made with love <3

I decided to biuld this, as didn't find single plain JavaScript script that actually works. Either that, or those would need whole jQuery with plugins for mouse scroll and stuff... This script is really small, and uses simple trick to preserve native mouse wheel / arrows scroll. It is done by css, and element that is actually scrolling is 50px wider than the parent. So native scroll bar is still there and works, but hidden from the eye of the user.

DEMO

Click here for demo.

Why you should use it

Usage

HTML, why three divs? We need three divs to preserve native scroll. I used to create other two in JavaScript, but that makes updating content and woking with events a lot harder. I switched back to manual HTML coding, but still I think it is pretty simple.

<div id="SOME_CSS_ID">
    <div class="scrollDiv">
        <div class="scrollContent">
            YOUR CONTENT HERE
        </div>
    </div>
</div>

Then just pass CSS selector, (in IE8 only CSS 2.1 selectors).

var rsSingle = new RS.RocketScroll('#scrollDiv');

var rsMultiple = new RS.RocketScroll('.scrollDiv');

.refresh(updateImagesOnload)

NOTICE!!! After manual updating the content, you need to call .refresh() method. It works for both single and multiple scrolls.

(Optional) If you send updateImagesOnload = true, method will call .refreshImages(). Default is false;

.refreshImages()

On init and content updating, script calls this method, to update itself on every image load.

Known issues

Looks like there is crapload of issues - but don't worry! Most of them are minor, and will be solved in reasonable time.

Please give suggestions, fork, upgrade, share, use and abuse it! Pull request are more than welcome :)

Hope you like it :) Cheers!