All Projects → noeldelgado → Gemini Scrollbar

noeldelgado / Gemini Scrollbar

Licence: mit
🌓 Custom overlay-scrollbars with native scrolling mechanism for web applications

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Gemini Scrollbar

Cyrillic To Translit Js
Ultra-lightweight JavaScript library for converting Cyrillic symbols to Translit and vice versa
Stars: ✭ 91 (-75.34%)
Mutual labels:  js-library
previewer
A super light-weight JavaScript image previewer [not actively maintained]
Stars: ✭ 24 (-93.5%)
Mutual labels:  js-library
awesome-libraries-resources
Awesome js and css libraries for web development.
Stars: ✭ 32 (-91.33%)
Mutual labels:  js-library
Selection
✨ Selection - A simple and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies. Full mobile and scroll support.
Stars: ✭ 1,371 (+271.54%)
Mutual labels:  js-library
Link Preview Js
Parse and/or extract web links meta information: title, description, images, videos, etc. [via OpenGraph], runs on mobiles and node.
Stars: ✭ 240 (-34.96%)
Mutual labels:  js-library
xijs
A business - oriented scene Js Library
Stars: ✭ 91 (-75.34%)
Mutual labels:  js-library
Redash
Tiny functional programming suite for JavaScript.
Stars: ✭ 40 (-89.16%)
Mutual labels:  js-library
Q5xjs
A small and fast alternative (experimental) implementation of p5.js
Stars: ✭ 334 (-9.49%)
Mutual labels:  js-library
FixLanguageTypeJs
Tiny Library for fix problem of language selection in type text.
Stars: ✭ 15 (-95.93%)
Mutual labels:  js-library
node-zklib
This is a lightweight of node.js module to connect to biometrix attendance device for examples ZKTeco
Stars: ✭ 43 (-88.35%)
Mutual labels:  js-library
Libapps Mirror
Mirror of the official libapps repo from https://chromium.googlesource.com/apps/libapps/
Stars: ✭ 103 (-72.09%)
Mutual labels:  js-library
Semantic Ui React
The official Semantic-UI-React integration
Stars: ✭ 12,561 (+3304.07%)
Mutual labels:  js-library
FilterInputJs
Tiny and Powerful Library for limit an entry (text box,input) as number,string or more...
Stars: ✭ 37 (-89.97%)
Mutual labels:  js-library
Values.js
🍇 Get the tints and shades of a color
Stars: ✭ 97 (-73.71%)
Mutual labels:  js-library
Alertism
A Good Replacement For Default JavaScript Alerts Which Also Makes Good Pop-Ups
Stars: ✭ 19 (-94.85%)
Mutual labels:  js-library
Bitsharesjs
JavaScript tools for BitShares Encryption and Serialization
Stars: ✭ 88 (-76.15%)
Mutual labels:  js-library
ChangeNumbersJs
Tiny Library for change number from a language in other language.
Stars: ✭ 14 (-96.21%)
Mutual labels:  js-library
Pickr
🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
Stars: ✭ 3,759 (+918.7%)
Mutual labels:  js-library
Anychart
AnyChart is a lightweight and robust JavaScript charting solution with great API and documentation. The chart types and unique features are numerous, the library works easily with any development stack.
Stars: ✭ 288 (-21.95%)
Mutual labels:  js-library
karthik558.github.io
It's just my Personal Portfolio Website, built with JAVASCRIPT | PHP | CSS | SASS | HTML ❤️
Stars: ✭ 18 (-95.12%)
Mutual labels:  js-library

gemini-scrollbar

npm-image bower-image license-image Known Vulnerabilities Dependencies Total alerts Language grade: JavaScript

Custom overlay-scrollbars with native scrolling mechanism for web applications (if needed).

There is a React wrapper too — react-gemini-scrollbar.

Problem Description

Nowadays, some OS’s provides “overlay-scrollbars” natively. Those scrollbars look nice and work well (mostly mobile browsers and OSX opt-in). The problem came when you have to customize the remaining ‘ugly’ scrollbars out there. e.g: “having a sidebar with a dark background + native-non-floating-scrollbars” ...hum, ugly. Even when this problem can be merely visual, for me is a way of enhancing the user experience.

Constraints
  • Fallbacks to use the native scrollbars when the OS/browser supports “overlay-scrollbars”.
  • Mimics the scrollbar behaviour when replaced with the custom ones (click, drag...).
  • IE9+ support.
Solution Proposal

Check the scrollbar size. If the scrollbar size is zero (which means the scrollbars are already “over the content”) then we do nothing. Otherwise we simply “hide” native scrollbar and show custom in its place.

Demo

https://noeldelgado.github.io/gemini-scrollbar/

Dependencies

None

Installation

NPM

npm i gemini-scrollbar --save

Bower

bower install gemini-scrollbar --save

Usage

JS

var GeminiScrollbar = require('gemini-scrollbar')

var myScrollbar = new GeminiScrollbar({
    element: document.querySelector('.my-scrollbar')
}).create();

LESS

@import (inline) "<path-to-gemini-scrollbar>/gemini-scrollbar.css";

CSS

@import url(<path-to-gemini-scrollbar>/gemini-scrollbar.css);

Or, you can add the relevant files in your document.

<link href="<path-to-gemini-scrollbar>/gemini-scrollbar.css" rel="stylesheet">
<script src="<path-to-gemini-scrollbar>/index.js"></script>

Options

name type default description
element * HTMLElement null The element to apply scrollbars
autoshow Boolean false Show scrollbars upon hovering
createElements Boolean true Create and append the require HTMLElements at runtime.
forceGemini Boolean false Force Gemini scrollbars even if native overlay-scrollbars are available. Useful for development.
onResize Function null Hook by which clients can be notified of resize events.
minThumbSize Number (px) 20 Sets the minimum size of the thumbs.

* required

Basic Methods

name description
create Bind the events, create the required elements and display the scrollbars.
update Recalculate the viewbox and scrollbar dimensions.
destroy Unbind the events and remove the custom scrollbar elements.

Other Mehods

name description
getViewElement Returns the scrollable element

Customization

You can change the styles of the scrollbars using CSS. e.g:

/* override gemini-scrollbar default styles */

/* vertical scrollbar track */
.gm-scrollbar.-vertical {
  background-color: #f0f0f0
}

/* horizontal scrollbar track */
.gm-scrollbar.-horizontal {
  background-color: transparent;
}

/* scrollbar thumb */
.gm-scrollbar .thumb {
  background-color: rebeccapurple;
}
.gm-scrollbar .thumb:hover {
  background-color: fuchsia;
}

Notes

  • native overlay-scrollbar: We check the scrollbar size using this approach by David Walsh. If the scrollbar size is zero (which means the scrollbars are “over the content”) then we do nothing but add the gm-prevented class selector to the element, which contains the non-standard -webkit-overflow-scrolling: touch; declaration for web devices to use momentum-based scrolling. No event binding, element creation... nothing, in this case, we leave the OS/browser do its job. Why? you already have nice looking scrollbars for free.

  • ::-webkit-scrollbar: If you plan to use gemini-scrollbar on your application I highly recommend you removing any Webkit scrollbar styles you may have, why? using the -webkit- prefixed pseudo-elements will cause Webkit turning off its built-in scrollbar rendering, interfering with our scrollbar-size-check. You can read a bit more about this issue on this commit.

  • create method: The custom scrollbars will not render until you call the create method on the instance. i.e: myScrollbar.create();

  • required height: To avoid unexpected results, it is recommended that you specify the height property with a value to the element you applying the custom scrollbars (or to its parent).

  • body tag: If you want to apply custom scrollbars to body, make sure to declare a height value either to the :root pseudo-class or to the html element. e.g:

    html {
        height: 100%;
        /* or */
        height: 100vh;
        overflow: hidden;
    }
    
  • createElements option: The createElements option specify wheater or not gemini-scrollbar should create and append the require HTMLElements at runtime. Its default value is true. Passing this option as false will assume that you to have added the required markup with the specific CSS class selectors on them for it to work. i.e:

    <!-- (createElements: false) example markup -->
    
    <div class="something-scrollable">
      <div class="gm-scrollbar -vertical">
        <div class="thumb"></div>
      </div>
      <div class="gm-scrollbar -horizontal">
        <div class="thumb"></div>
      </div>
      <div class="gm-scroll-view">
        All your content goes here.
      </div>
    </div>
    

This way you can be sure the library will not touch/change your nodes structure. You can read more about the reason of this option on this commit.

Related

License

MIT © Noel Delgado

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].