mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-23 13:30:37 +03:00
improve documentation
This commit is contained in:
@@ -5,21 +5,22 @@ I created this plugin because I hate ugly and space consuming scrollbars. Simila
|
||||
## Goals & Features
|
||||
|
||||
- Simple, powerful and well documented API
|
||||
- High browser compatibility - <b>Firefox 59+</b>, <b>Chrome 55+</b>, <b>Opera 42+</b>, <b>Edge 12+</b>, <b>Safari 10+</b> and <b>IE 11</b>
|
||||
- Can be run on the server - <b>SSR</b>, <b>SSG</b> and <b>ISR</b> support
|
||||
- Tested on various devices - <b>Mobile</b>, <b>Desktop</b> and <b>Tablet</b>
|
||||
- Tested with various (and mixed) inputs - <b>Mouse</b>, <b>touch</b> and <b>pen</b>
|
||||
- <b>Treeshaking</b> - bundle only what you really need
|
||||
- Automatic update detection - <b>no polling</b>
|
||||
- Usage of latest browser features - best <b>performance</b> in new browsers
|
||||
- High browser compatibility - **Firefox 59+**, **Chrome 55+**, **Opera 42+**, **Edge 12+**, **Safari 10+** and **IE 11**
|
||||
- Can be run on the server - **SSR**, **SSG** and **ISR** support
|
||||
- Tested on various devices - **Mobile**, **Desktop** and **Tablet**
|
||||
- Tested with various (and mixed) inputs - **Mouse**, **touch** and **pen**
|
||||
- **Treeshaking** - bundle only what you really need
|
||||
- Automatic update detection - **no polling**
|
||||
- Usage of latest browser features - best **performance** in new browsers
|
||||
- Bidirectional - LTR or RTL direction support
|
||||
- Supports usage on the `body` element
|
||||
- Supports all **virtual scrolling** libraries
|
||||
- Simple and effective scrollbar styling
|
||||
- Highly customizable
|
||||
- TypeScript support - fully written in TypeScript
|
||||
- Dependency free - 100% self written to ensure small size and best functionality
|
||||
- High quality and fully typed framework versions for [`react`](https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-react), [`vue`](https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-vue), [`angular`](https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-ngx), [`svelte`](https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-svelte) and [`solid`](https://github.com/KingSora/OverlayScrollbars/tree/master/packages/overlayscrollbars-solid).
|
||||
|
||||
|
||||
## Choose your framework
|
||||
|
||||
Additionally to the vanilla JavaScript version you can use the official framework components & utilities:
|
||||
@@ -34,7 +35,8 @@ Additionally to the vanilla JavaScript version you can use the official framewor
|
||||
|
||||
## Getting started
|
||||
|
||||
### npm & node
|
||||
### npm & nodejs
|
||||
|
||||
OverlayScrollbars can be downloaded from [npm](https://www.npmjs.com/package/overlayscrollbars) or the package manager of your choice:
|
||||
```sh
|
||||
npm install overlayscrollbars
|
||||
@@ -42,39 +44,42 @@ npm install overlayscrollbars
|
||||
After installation it can be imported:
|
||||
```js
|
||||
import 'overlayscrollbars/overlayscrollbars.css';
|
||||
import { OverlayScrollbars } from 'overlayscrollbars';
|
||||
import {
|
||||
OverlayScrollbars,
|
||||
ScrollbarsHidingPlugin,
|
||||
SizeObserverPlugin,
|
||||
ClickScrollPlugin
|
||||
} from 'overlayscrollbars';
|
||||
```
|
||||
|
||||
> __Note__: In older node versions use `'overlayscrollbars/styles/overlayscrollbars.css'` as the import path for the CSS file.
|
||||
> __Note__: In older nodejs versions use `'overlayscrollbars/styles/overlayscrollbars.css'` as the import path for the CSS file.
|
||||
|
||||
### Manual download & embedding
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
These instructions are for quick prototyping or old stacks. Click here to read them.
|
||||
</summary>
|
||||
<br />
|
||||
|
||||
You can use OverlayScrollbars without any bundler or package manager.
|
||||
Simply download it from the [Releases](https://github.com/KingSora/OverlayScrollbars/releases) or use a [CDN](https://cdnjs.com/libraries/overlayscrollbars).
|
||||
|
||||
- Use the javascript files with the `.browser` extension.
|
||||
- If you target old browsers use the `.es5` javascript file, for new browsers `.es6`.
|
||||
- Use the javascript files with the `.es5` extension if you need to support older browsers like IE11, otherwise use the `.es6` files.
|
||||
- For production use the javascript / stylesheet files with the `.min` extension.
|
||||
|
||||
Embedd OverlayScrollbars manually in your HTML:
|
||||
```html
|
||||
<link type="text/css" href="path/to/overlayscrollbars.css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="path/to/overlayscrollbars.js" defer></script>
|
||||
<script type="text/javascript" src="path/to/overlayscrollbars.browser.es.js" defer></script>
|
||||
```
|
||||
|
||||
You can use the global variable `OverlayScrollbarsGlobal` to access the api:
|
||||
You can then use the global variable `OverlayScrollbarsGlobal` to access the api similar to how you can do it in nodejs / modules:
|
||||
```js
|
||||
var OverlayScrollbars = OverlayScrollbarsGlobal.OverlayScrollbars;
|
||||
OverlayScrollbars(document.body, {});
|
||||
var {
|
||||
OverlayScrollbars,
|
||||
ScrollbarsHidingPlugin,
|
||||
SizeObserverPlugin,
|
||||
ClickScrollPlugin
|
||||
} = OverlayScrollbarsGlobal;
|
||||
```
|
||||
</details>
|
||||
|
||||
The examples in this documentation will use the `import` syntax instead of the `OverlayScrollbarsGlobal` object. Both versions are equivalent though.
|
||||
|
||||
## Initialization
|
||||
|
||||
@@ -507,7 +512,7 @@ Custom themes can be done in multiple ways. The easiest and fastest is to use th
|
||||
}
|
||||
```
|
||||
|
||||
You can alter the properties either for both scrollbars at once or per scrollbar axis:
|
||||
You can alter the properties either for both scrollbars at once or per scrollbar axis. In the example below I've chosen `os-theme-custom` as the theme name:
|
||||
|
||||
```scss
|
||||
// horizontal and vertical scrollbar are 10px
|
||||
@@ -525,6 +530,16 @@ Custom themes can be done in multiple ways. The easiest and fastest is to use th
|
||||
}
|
||||
```
|
||||
|
||||
You can then use your theme by assigning it via the `scrollbars.theme` option:
|
||||
|
||||
```js
|
||||
OverlayScrollbars(document.body, {
|
||||
scrollbars: {
|
||||
theme: 'os-theme-custom'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Since scrollbar styles are usually simple, this set of options should be enough to get your desired styling.
|
||||
In case you need more freedom you can create your own styles by adding styling to the base class names described in the next section.
|
||||
|
||||
@@ -564,6 +579,13 @@ Custom themes can be done in multiple ways. The easiest and fastest is to use th
|
||||
|
||||
If you create your own theme, please only use the classes listed above. All other classes are modifier classes used to change visibility, alignment and pointer-events of the scrollbars.
|
||||
|
||||
### Gotchas
|
||||
|
||||
Its important that the chosen theme class name in your CSS file matches the assigned theme name in the options. If the CSS class name is `.my-theme` the `scrollbars.theme` has to be `'my-theme'`.
|
||||
|
||||
|
||||
Please be aware of your stack. `css-modules` for example will alter your class names to prevent naming collisions. Always double check if your CSS is really what you expect it to be.
|
||||
|
||||
</details>
|
||||
|
||||
## Plugins
|
||||
|
||||
Reference in New Issue
Block a user