SlimScroll EXTENSION slimScroll is a small (2.8KB) jQuery plugin that transforms any div into a scrollable area with a nice scrollbar - similar to the one Facebook and Google started using.

About

slimScroll is a small (4.6KB) jQuery plugin that transforms any div into a scrollable area with a nice scrollbar - similar to the one Facebook and Google started using in their products recently. slimScroll doesn't occupy any visual space as it only appears on a user initiated mouse-over. User can drag the scrollbar or use mouse-wheel to change the scroll value.

SlimScroll has been around for a long time, and it is very stable and extreamly lightweight. In all sense of the word it gets the job done efficiently.

Example for Size, position and direction

The example below we use the following codes for position: 'left', height: '300px', railVisible: true, alwaysVisible: true

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed diam sem, imperdiet at mollis vestibulum, bibendum id purus. Aliquam molestie, leo sed molestie condimentum, massa enim lobortis massa, in vulputate diam lorem quis justo. Nullam nec dignissim mi. In non varius nibh. Proin et eros nisi, eu vulputate libero. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultricies augue id risus dapibus blandit.

Integer malesuada molestie dolor sit amet viverra. Mauris nec urna lorem. Integer commodo feugiat ligula eget fermentum. In in tellus a risus convallis pellentesque. Cras non faucibus est. Morbi sagittis risus mollis nisl mollis ac mattis mi volutpat. Vivamus ac rutrum elit. Suspendisse semper orci vitae sapien sollicitudin mattis.

Integer malesuada molestie dolor sit amet viverra. Mauris nec urna lorem. Integer commodo feugiat ligula eget fermentum. In in tellus a risus convallis pellentesque. Cras non faucibus est. Morbi sagittis risus mollis nisl mollis ac mattis mi volutpat. Vivamus ac rutrum elit. Suspendisse semper orci vitae sapien sollicitudin mattis.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed diam sem, imperdiet at mollis vestibulum, bibendum id purus. Aliquam molestie, leo sed molestie condimentum, massa enim lobortis massa, in vulputate diam lorem quis justo. Nullam nec dignissim mi. In non varius nibh. Proin et eros nisi, eu vulputate libero. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultricies augue id risus dapibus blandit.

Example for width and color

The example below we use color: myapp_get_color.primary_700, size: '20px', height: '300px', alwaysVisible: true

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed diam sem, imperdiet at mollis vestibulum, bibendum id purus. Aliquam molestie, leo sed molestie condimentum, massa enim lobortis massa, in vulputate diam lorem quis justo. Nullam nec dignissim mi. In non varius nibh. Proin et eros nisi, eu vulputate libero. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultricies augue id risus dapibus blandit.

Integer malesuada molestie dolor sit amet viverra. Mauris nec urna lorem. Integer commodo feugiat ligula eget fermentum. In in tellus a risus convallis pellentesque. Cras non faucibus est. Morbi sagittis risus mollis nisl mollis ac mattis mi volutpat. Vivamus ac rutrum elit. Suspendisse semper orci vitae sapien sollicitudin mattis.

Integer malesuada molestie dolor sit amet viverra. Mauris nec urna lorem. Integer commodo feugiat ligula eget fermentum. In in tellus a risus convallis pellentesque. Cras non faucibus est. Morbi sagittis risus mollis nisl mollis ac mattis mi volutpat. Vivamus ac rutrum elit. Suspendisse semper orci vitae sapien sollicitudin mattis.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed diam sem, imperdiet at mollis vestibulum, bibendum id purus. Aliquam molestie, leo sed molestie condimentum, massa enim lobortis massa, in vulputate diam lorem quis justo. Nullam nec dignissim mi. In non varius nibh. Proin et eros nisi, eu vulputate libero. Suspendisse potenti. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis ultricies augue id risus dapibus blandit.

Scripts and config

Config options
code type what it does
width string Width in pixels of the visible scroll area. Stretch-to-parent if not set. Default: none
height string Height in pixels of the visible scroll area. Also supports auto to set the height to same as parent container. Default: 250px
size string Width in pixels of the scrollbar. Default: 7px
position string left or right. Sets the position of the scrollbar. Default: right
color string Color in hex of the scrollbar. Default: #000000
alwaysVisible bool Disables scrollbar hide. Default: false
distance string Distance in pixels from the edge of the parent element where scrollbar should appear. It is used together with position property. Default:1px
start string top or bottom or $(selector) - defines initial position of the scrollbar. When set to bottom it automatically scrolls to the bottom of the scrollable container. When HTML element is passed, slimScroll defaults to offsetTop of this element. Default: top.
wheelStep integer Integer value for mouse wheel delta. Default: 20
railVisible bool Enables scrollbar rail. Default: false
railColor string Sets scrollbar rail color, Default: #333333
railOpacity integer Sets scrollbar rail opacity. Default: 0.2
allowPageScroll bool Checks if mouse wheel should scroll page when bar reaches top or bottom of the container. When set to true is scrolls the page.Default: false
scrollTo string Jumps to the specified scroll value. Can be called on any element with slimScroll already enabled. Example: $(element).slimScroll({ scrollTo: '50px' });
scrollBy string Increases/decreases current scroll value by specified amount (positive or negative). Can be called on any element with slimScroll already enabled. Example: $(element).slimScroll({ scrollBy: '60px' });
disableFadeOut bool Disables scrollbar auto fade. When set to true scrollbar doesn't disappear after some time when mouse is over the slimscroll div.Default: false
touchScrollStep integer Allows to set different sensitivity for touch scroll events. Negative number inverts scroll direction.Default: 200
Initialize manually
$('#slimscroll').slimScroll({
	position: 'left',
	height: '300px',
	railVisible: true,
	alwaysVisible: true
}); 
Initliza with data attributes
<div id="slimscroll" class="custom-scroll" style="height:300px" 
        data-scrollHeight="300" 
        data-scrollSize="4px" 
        data-scrollPosition="right" 
        data-scrollColor="rgba(0,0,0,0.6)" 
        data-alwaysVisible="false" 
        data-distance="4px" 
        data-railVisible="false" 
        data-railColor="#fafafa" >
  <div class="p-3">
    ...
    content...
    ...
  </div>
</div>
Destroy
$('#slimscroll').slimScroll({ destroy: true });
$('#slimscroll').attr('style', '');