Lightweight and Custom Scrollbar For Pure Javascript | Sheepbar.js

Sheepbar is a lightweight, simple scrollbar in pure JavaScript that attaches a simple, easy-to-style slider to a DIV element that contains the large web content.

  •  Support for mobile devices
  •  Slimming and optimization
  •  Maybe more optymalization

Must Read: Minimalistic Custom Slider Scrollbar Plugin | Perfect slider

Simple Scrollbar In Pure Javascript

Post NameCustom Scrollbar CSS For Div
Author NameSzymonLisowiec
CategoryScrolling
Official PageClick Here | Click Here
Official Websitegithub.com
Publish DateMarch 19, 2022
Last UpdateAugust 6, 2023
DownloadLink Below
LicenseMIT

Simple CSS

  • .sheepbar>.sheepbar-scrollbox – Container of content
  • .sheepbar>.sheepbar-scrollbox>.sheepbar-content – Content
  • .sheepbar>.sheepbar-scrollbar – Container of scrollbar pointer
  • .sheepbar>.sheepbar-scrollbar>div – Scrollbar pointer

Options

  • position – CSS position (Have to be absolute, relative, or fixed). [string] [Default: relative]
  • callback_scroll – callback of event “scroll” [function] [Default: empty function]
  • callback_mousedown – callback of event “mousedown” [function] [Default: empty function]
  • callback_mouseup – callback of event “mouseup” [function] [Default: empty function]
  • callback_mousemove – callback of event “mousemove” [function] [Default: empty function]
  • callback_resize – callback of event “resize” [function] [Default: empty function]

How to make use of it:

1. Put the main JavaScript file Sheepbar.js into the document:

<script src="sheepbar.js"></script>

2. Configure the Sheepbar.

var Sheepbar = new Sheepbar();

3. Add the CSS class “Sheep Bar” to the scrollable DIV container.

<div class="sheepbar">
  ...
</div>

4. Disable/enable the horizontal and vertical scroll bars.

<div class="sheepbar"
     data-x="true" 
     data-y="true">
  ...
</div>

5. Customize the scrollbar in CSS as shown below:

.sheepbar>.sheepbar-scrollbar>div {
  width: 100%;
  height: 96%;
  top: 2%;
  bottom: 2%;
  left: 0;
  position: absolute;
  border-radius: 6px;
  background: #34495e;
  opacity: 0.52;
  transition: opacity 0.2s;
  cursor: pointer;
}
.sheepbar>.sheepbar-scrollbar.sheepbar-x>div {
  width: 96%;
  height: 100%;
  right: 2%;
  bottom: 0;
  left: 2%;
}
.sheepbar>.sheepbar-scrollbar>div:hover, .sheepbar>.sheepbar-scrollbar>div:active { opacity: 0.88; }
.sheepbar>.sheepbar-scrollbar.sheepbar-x {
  height: 6px;
  bottom: 2px;
}
.sheepbar>.sheepbar-scrollbar.sheepbar-y {
  width: 6px;
  right: 2px;
}
.sheepbar .sheepbar-content {
  padding: 0 12px 0 12px;
}

6. Available customization options and callback functions.

var Sheepbar = new Sheepbar({
    // CSS position
    position: 'relative',
    // Callbacks
    callback_scroll: function(){},
    callback_mousedown: function(){},
    callback_mouseup: function(){},
    callback_mousemove: function(){},
    callback_resize: function(){}
    
});

See Demo And Download

custom-scrollbar-css-for-div

Official Website(SzymonLisowiec): Click Here

This superior jQuery/javascript plugin is developed by SzymonLisowiec. For extra Advanced Usage, please go to the official website.

Related Posts

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Data-Table-Generator-Tabulator

Interactive Data Table Generator with JS/jQuery and JSON | Tabulator

Tabulator allows you to create interactive tables in seconds from any HTML Table, JavaScript array, AJAX data source, or JSON format data. Just include the library in your…

alert-confirm-prompt-attention-js

Simple Alert, Confirm, Prompt Popup Using Vanilla JavaScript Library | attention.js

JavaScript provides various built-in functionality to display popup messages for different purposes. Attention JS is a vanillaJS plugin used to create a custom alert, confirm, or Prompt…

Leave a Reply

Your email address will not be published. Required fields are marked *