All Projects → KingSora → Overlayscrollbars

KingSora / Overlayscrollbars

Licence: mit
A javascript scrollbar plugin which hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
typescript
32286 projects
Vue
7211 projects
HTML
75241 projects

Projects that are alternatives of or similar to Overlayscrollbars

Smooth Scrollbar
Customizable, Pluginable, and High-Performance JavaScript-Based Scrollbar Solution.
Stars: ✭ 2,695 (+31.21%)
Mutual labels:  scrollbar, javascript-scrollbar-plugin
vue-scrolly
Overlay scrollbar for Vue.js.
Stars: ✭ 24 (-98.83%)
Mutual labels:  scrollbar, overlay-scrollbars
Perfect Scrollbar
Minimalistic but perfect custom scrollbar plugin. Get more free components with Material Design for Bootstrap UI Kit (link below)
Stars: ✭ 8,593 (+318.35%)
Mutual labels:  frontend, scrollbar-plugin
Webapp.rs
A web application completely written in Rust. 🌍
Stars: ✭ 1,888 (-8.08%)
Mutual labels:  frontend
Blog
阿翔的个人技术博客,博文写在 Issues 里,如有收获请 star 鼓励~
Stars: ✭ 135 (-93.43%)
Mutual labels:  frontend
Learnquery
Learn JavaScript fundamentals by building your own jQuery equivalent library
Stars: ✭ 136 (-93.38%)
Mutual labels:  frontend
Frontend Download Sample
🎄 自己整理的一些项目中遇到过的关于上传和下载的一些Demo,仅供给位看官参考,避免踩坑,即插即用,欢迎fork和star🌟,为这个仓库添砖加瓦~(P.S. 个人认为如果没写过上传下载其实还是挺麻烦的~)
Stars: ✭ 142 (-93.09%)
Mutual labels:  frontend
Handoff Visualizer
📶📱🚗 Wireless Network Handoff Visualizer built with React!
Stars: ✭ 134 (-93.48%)
Mutual labels:  frontend
Awesome Ember
A curated list of awesome Ember.js stuff like addons, articles, videos, gists and more.
Stars: ✭ 140 (-93.18%)
Mutual labels:  frontend
Framework
Strongly-typed JavaScript object with support for validation and error handling.
Stars: ✭ 136 (-93.38%)
Mutual labels:  frontend
Tensor
Tensor - Comprehensive web-based automation framework and Centralized infrastructure management platform
Stars: ✭ 136 (-93.38%)
Mutual labels:  frontend
Oxygen Updater
Oxygen Updater App - faster access to OnePlus system updates. Be the first to update!
Stars: ✭ 135 (-93.43%)
Mutual labels:  frontend
Spring Boot Vuejs
Example project showing how to build a Spring Boot App providing a GUI with Vue.js
Stars: ✭ 1,818 (-11.49%)
Mutual labels:  frontend
Portfolio Generator
JS framework to dynamically generate a portfolio site from a JSON file
Stars: ✭ 135 (-93.43%)
Mutual labels:  frontend
Frontenddaily
前端开发博客,分享互联网最精彩的前端技术,欢迎关注我微信公众号:前端开发博客,回复 1024,领取前端进阶资料包,回复 加群,与大神一起交流学习。
Stars: ✭ 1,901 (-7.45%)
Mutual labels:  frontend
Fe Interview
😃 每日一道经典前端面试题,一起共同成长。
Stars: ✭ 134 (-93.48%)
Mutual labels:  frontend
Pygdbmi
A library to parse gdb mi output and interact with gdb subprocesses
Stars: ✭ 139 (-93.23%)
Mutual labels:  frontend
Reactpatterns
Patterns for React Developers
Stars: ✭ 1,682 (-18.11%)
Mutual labels:  frontend
Todomvc Ddd Cqrs Eventsourcing
Implementation of basic Todo app via tastejs/todomvc in C#/Typescript with eventsourcing, cqrs, and domain driven design
Stars: ✭ 134 (-93.48%)
Mutual labels:  frontend
Books
一些前端/设计相关的书籍(电子书)
Stars: ✭ 134 (-93.48%)
Mutual labels:  frontend

OverlayScrollbars

Dependencies Downloads Version License

Website   •   Documentation   •   Demos   •   Extensions   •   FAQ

OverlayScrollbars is a javascript scrollbar plugin which hides native scrollbars, provides custom styleable overlay scrollbars and keeps the native functionality and feeling.

Why

I've created this plugin because I hate ugly and space consuming scrollbars. Similar plugins haven't met my requirements in terms of features, quality, simplicity, license or browser support.

Goals & Features

  • A simple, powerful and good documented API.
  • High browser compatibility (IE8+, Safari6+, Firefox, Opera, Chrome and Edge).
  • Usage of the most recent technologies to ensure maximum efficiency and performance on newer browsers.
  • Can be used without any dependencies or with jQuery.
  • Automatic update detection - after the initialization you don't have to worry about updating.
  • Extremely powerful scroll method with features like animations, relative coordinates, scrollIntoView and more.
  • Mouse and touch support.
  • Textarea and Body support.
  • RTL Direction support. (with normalization)
  • Simple and effective scrollbar-styling.
  • Rich extension system.
  • TypeScript support.

Framework Wrapper

OverlayScrollbars provides its own wrapper components for popular component-based front-end frameworks:

React

Version Downloads README

npm install overlayscrollbars-react

Vue

Version Downloads README

npm install overlayscrollbars-vue

Angular

Version Downloads README

npm install overlayscrollbars-ngx

Sponsors

Thanks to BrowserStack for sponsoring open source projects and letting me test OverlayScrollbars for free.

Dependencies

The default version doesn't requires any dependencies!

If you are using the jQuery dependent version it obviously requires jQuery to work.
It was tested with the jQuery versions: 1.9.1, 2.x, 3.x, and it won't work with jQuery slim.

Download

manually

Download OverlayScrollbars manually from Releases.

cdn

You can use OverlayScrollbars via a cdn.

npm

OverlayScrollbars can be downloaded from npm.

npm install overlayscrollbars

Usage

HTML

Load your CSS file(s) before the JS file(s), to prevent unexpected bugs.

Include OverlayScrollbars.css and OverlayScrollbars.js to your HTML file.

<!-- Plugin CSS -->
<link type="text/css" href="path/to/OverlayScrollbars.css" rel="stylesheet"/>
<!-- Plugin JS -->
<script type="text/javascript" src="path/to/OverlayScrollbars.js"></script>

If you are using the jQuery version, include jQuery before the plugin and use jquery.overlayScrollbars.js

<!-- Plugin CSS -->
<link type="text/css" href="path/to/OverlayScrollbars.css" rel="stylesheet"/>
<!-- jQuery JS -->
<script type="text/javascript" src="path/to/jquery.js"></script>
<!-- Plugin JS -->
<script type="text/javascript" src="path/to/jquery.overlayScrollbars.js"></script>

JavaScript

Initialize the plugin after your document has been fully loaded.

Default initialization:

document.addEventListener("DOMContentLoaded", function() {
    //The first argument are the elements to which the plugin shall be initialized
    //The second argument has to be at least a empty object or a object with your desired options
    OverlayScrollbars(document.querySelectorAll('body'), { });
});

jQuery initialization:

$(function() {
    //The passed argument has to be at least a empty object or a object with your desired options
    $('body').overlayScrollbars({ });
});

TypeScript

OverlayScrollbars provides its own TypeScript declarations:

npm install @types/overlayscrollbars

I recommend setting these options in your tsconfig.json:

{
    "compilerOptions": {
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": true
    }
}

Options

Due to clarity I can't provide all informations here.
Take the table below only as a overview of all options.
Please read the much more detailed documentation.

option type default description
className string / null "os-theme-dark" The class name which shall be added to the host element.
resize string "none" The resize behavior of the host element. This option works exactly like the CSS3 resize property.
sizeAutoCapable boolean true Indicates whether the host element is capable of "auto" sizes such as: width: auto and height: auto.
clipAlways boolean true Indicates whether the content shall be clipped always.
normalizeRTL boolean true Indicates whether RTL scrolling shall be normalized.
paddingAbsolute boolean false Indicates whether the padding for the content shall be absolute.
autoUpdate boolean / null null Indicates whether the plugin instance shall be updated continuously within a update loop.
autoUpdateInterval number 33 The interval in milliseconds in which a auto update shall be performed for this instance.
updateOnLoad string / array / null ["img"] Selectors of which the elements load event shall be handled by the plugin. Thats means OverlayScrollbars will trigger a automatic update if a element with a matching selector emits a load event. Per default OverlayScrollbars will update automatically if a img element loads.
nativeScrollbarsOverlaid : {
showNativeScrollbars boolean false Indicates whether the native overlaid scrollbars shall be visible.
initialize boolean true Indicates whether the plugin shall be initialized even if the native scrollbars are overlaid.
If you initialize the plugin on the body element, I recommend to set this option to false.
}
overflowBehavior : {
x string "scroll" The overflow behavior for the x (horizontal) axis.
y string "scroll" The overflow behavior for the y (vertical) axis.
}
scrollbars : {
visibility string "auto" The basic visibility of the scrollbars.
autoHide string "never" The possibility to hide visible scrollbars automatically after a certain action.
autoHideDelay number 800 The delay in milliseconds before the scrollbars gets hidden automatically.
dragScrolling boolean true Defines whether the scrollbar-handle supports drag scrolling.
clickScrolling boolean false Defines whether the scrollbar-track supports click scrolling.
touchSupport boolean true Indicates whether the scrollbar reacts to touch events.
snapHandle boolean false Indicates whether the scrollbar handle-offset shall be snapped.
}
textarea : {
dynWidth boolean false Indicates whether the textarea width will be dynamic (content dependent).
dynHeight boolean false Indicates whether the textarea height will be dynamic (content dependent).
inheritedAttrs string / array / null ["style", "class"] During initialization: Attributes which the generated host-element shall inherit from from the target textarea-element.
During destruction: Attributes which the target textarea-element shall inherit from from the generated host-element.
}
callbacks : {
onInitialized function / null null Gets fired after the plugin was initialized. It takes no arguments.
onInitializationWithdrawn function / null null Gets fired after the initialization of the plugin was aborted due to the option nativeScrollbarsOverlaid : { initialize : false }. It takes no arguments.
onDestroyed function / null null Gets fired after the plugin was destryoed. It takes no arguments.
onScrollStart function / null null Gets fired after the user starts scrolling. It takes one argument.
onScroll function / null null Gets fired after every scroll. It takes one argument.
onScrollStop function / null null Gets fired after the user stops scrolling. It takes one argument.
onOverflowChanged function / null null Gets fired after the overflow has changed. It takes one argument.
onOverflowAmountChanged function / null null Gets fired after the overflow amount has changed. It takes one argument.
onDirectionChanged function / null null Gets fired after the direction has changed. It takes one argument.
onContentSizeChanged function / null null Gets fired after the content size has changed. It takes one argument.
onHostSizeChanged function / null null Gets fired after the host size or host padding has changed. It takes one argument.
onUpdated function / null null Gets fired after the host size has changed. It takes one argument.
}

Methods

Click on the method name to open a more detailed documentation.

Instance methods:

name description
.options() Returns or sets the options of the instance.
example(s):
//get options
var options = instance.options();
//set options
instance.options({ className : null });
.update() Updates the instance.
example(s):
//soft update
instance.update();
//hard update
instance.update(true);
.sleep() Disables every observation of the DOM and puts the instance to "sleep". This behavior can be reset by calling the update() method.
example(s):
//put the instance to sleep
instance.sleep();
.scroll() Returns the scroll information or sets the scroll position.
example(s):
//get scroll information
var scrollInfo = instance.scroll();
//scroll 50px on both axis
instance.scroll(50);
//add 10px to the scroll offset of each axis
instance.scroll({ x : "+=10", y : "+=10" });
//scroll to 50% on both axis with a duration of 1000ms
instance.scroll({ x : "50%", y : "50%" }, 1000);
//scroll to the passed element with a duration of 1000ms
instance.scroll($(selector), 1000);
.scrollStop() Stops the current scroll-animation.
example(s):
//scroll-animation duration is 10 seconds
instance.scroll({ y : "100%" }, 10000);
//abort the 10 seconds scroll-animation immediately
instance.scrollStop();
//scroll-animation duration is 1 second
instance.scroll({ y : "100%" }, 1000);
.getElements() Returns all relevant elements.
example(s):
//get the element to which the plugin was applied
var pluginTarget = instance.getElements().target;
.getState() Returns a object which describes the current state of this instance.
example(s):
//get the state of the plugin instance
var pluginState = instance.getState();
.destroy() Destroys and disposes the current instance and removes all added elements form the DOM.
example(s):
//destroy the instance
instance.destroy();
.ext() Returns the instance of a certain extension of the current plugin instance.
example(s):
//get the instance of the extension "myExtension"
var extensionInstance = instance.ext("myExtension");
.addExt() Adds a extension to the current instance.
example(s):
//add the registered extension "myExtension" to the plugin instance
var extensionInstance = instance.addExt("myExtension");
.removeExt() Removes a extension from the current instance.
example(s):
//add the registered extension "myExtension" to the plugin instance
instance.addExt("myExtension");
//remove the added extension "myExtension" from the plugin instance
instance.removeExt("myExtension");

Global methods:

name description
OverlayScrollbars.defaultOptions() Returns or Sets the default options for each new plugin initialization.
example(s):
//get the current defaultOptions
var defaultOptions = OverlayScrollbars.defaultOptions();
//set new default options
OverlayScrollbars.defaultOptions({
    className : "my-custom-class",
    resize    : "both"
});
OverlayScrollbars.globals() Returns a plain object which contains global information about the plugin and each instance of it.
example(s):
//get the global information
var globals = OverlayScrollbars.globals();
OverlayScrollbars.extension() Registers, Unregisters or returns extensions.
example(s):
//register a dummy extension with the name "myExtension"
OverlayScrollbars.extension("myExtension", function() { return { }; });
//unregister the extension with the name "myExtension"
OverlayScrollbars.extension("myExtension", null);
//get the extension-object with the name "myExtension"
var registeredExtension = OverlayScrollbars.extension("myExtension");
//get all registered extension-objects
var extensionObjects = OverlayScrollbars.extension();
OverlayScrollbars.valid() Checks whether the passed object is a non-destroyed OverlayScrollbars instance.
example(s):
//create OverlayScrollbars instance
var osInstance = OverlayScrollbars(document.body, { });
//returns true
OverlayScrollbars.valid(osInstance);
//destroy the instance
osInstance.destroy();
//returns false
OverlayScrollbars.valid(osInstance);
//returns false
OverlayScrollbars.valid({ });

Tests

It's a challenge to fully test a library like OverlayScrollbars, because it has to adapt to countless DOM setups and browsers. Nevertheless I've developed basic GUI-Tests. In these tests a element with applied OverlayScrollbars is compared to a native element.

You can run the tests by visiting this page and clicking on the Run button. Please be aware that the tests need some time to complete. After the process is complete, the results are displayed in the console.

In case some tests are failing on your end, please open a issue with the console output of the tests (the failed array in particular).

Future Plans

  • Minimize the code as much as possible.
  • Frequent updates in terms of bug-fixes and enhancements.
  • Improve tests

License

MIT

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].