Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/enriquebv/vue-overlayscrollbars

Vue directive to override the native scrollbar, with OverlayScrollbars.
https://github.com/enriquebv/vue-overlayscrollbars

Last synced: 19 days ago
JSON representation

Vue directive to override the native scrollbar, with OverlayScrollbars.

Awesome Lists containing this project

README

        

# vue-overlayscrollbars

Vue directive to override the native scrollbar, with OverlayScrollbars.

### To do

- [x] Vue directive
- [x] Options support (with reactive support).
- [ ] Fancy demo.

## How to use

1. Download the plugin and OverlayScrollbars (just for the css):

```bash
// With npm
npm install vue-overlayscrollbars --save-dev

// Or yarn
yarn add vue-overlayscrollbars
```

2. Add it to Vue:

```js
import Vue from "vue";
import VueOverlayScrollbars from "vue-overlayscrollbars";

Vue.use(VueOverlayScrollbars);
```

3. Require the CSS:

```js
// Using the OverlayScrollbars default (included in plugin).
import "vue-overlayscrollbars/dist/vue-overlayscrollbars.css";

// Or using any download template from https://kingsora.github.io/OverlayScrollbars/#!themes
import "your/downloaded/theme.css";
```

4. Add the directive `v-scrollbar` to any container in your templates:

```html


    ```

    5. And voila, you have OverlayScrollbars in Vue, the most easy way.

    ## OverlayScrollbars options

    Just pass it with the directive:

    ```html

    export default {
    data() {
    return {
    options: {
    className: "os-theme-dark",
    resize: "none",
    sizeAutoCapable: true,
    clipAlways: true,
    normalizeRTL: true,
    paddingAbsolute: false,
    autoUpdate: null
    // Same options used in Vanilla JavaScript version
    // https://kingsora.github.io/OverlayScrollbars/#!documentation/options.
    }
    };
    }
    };

    ```

    ## Get the instance

    The OverlayScrollbar instance will be stored in the same element where you use the directive:

    ```html

    export default {
    data() {
    return {
    options: {
    ...
    }
    };
    },
    mounted() {
    console.info(this.$refs.element._os); // _os attribute in the element it's the OverlayScrollbar instance.
    }
    };

    ```