Accessible fixed Sidebar with Smart Scroll.
There is different cases when you are using sidebar and often CSS just not enough to make it user friendly. What scenarios you should be considered to make sidebar always accessible.
To make it happen was created sidescroll.js plugin.
To checkout all scenarios try live demo.
bower install sidescroll
or grab the source version or minified version and put it right before closing body tag or into head after jQuery.
...
<script src="pathto/jquery.min.js"></script>
<script src="pathto/jquery.sidescroll.min.js"></script>
<script>
$('.sidebar').sideScroll();
</script>
</body>
</html>
Init sideScroll method to your sidebar
$('.sidebar').sideScroll();
add a line of CSS to your styles
.sidebar.is-fixed {
position: fixed;
top: 0;
}
Name | Type | Default value | Description |
---|---|---|---|
content | selector |
'.container' |
container selector |
fixedClass | string |
'is-fixed' |
sidebar fixed class name |
$('.sidebar').sideScroll({
content: '.my-content',
fixedClass: 'my-fixed'
});
Name | Description |
---|---|
start | plugin initialize, also can be used as continue after stop |
stop | plugin stops working, but saved current position |
clear | plugin stops working and reset sidebar position |
$('.sidebar').sideScroll('start');
$('.sidebar').sideScroll('stop');
$('.sidebar').sideScroll('clear');
This overrides fixed class name, which applying to sidebar
I'll check out your contribution if you:
- Have a clear and comprehensive description for your changes in pull request.
MIT