Giter VIP home page Giter VIP logo

vue-overlayscrollbars's Introduction

vue-overlayscrollbars

Vue directive to override the native scrollbar, with OverlayScrollbars.

To do

  • Vue directive
  • Options support (with reactive support).
  • Fancy demo.

How to use

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

    // With npm
    npm install vue-overlayscrollbars --save-dev
    
    // Or yarn
    yarn add vue-overlayscrollbars
  2. Add it to Vue:

    import Vue from "vue";
    import VueOverlayScrollbars from "vue-overlayscrollbars";
    
    Vue.use(VueOverlayScrollbars);
  3. Require the CSS:

    // 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:

    <div v-scrollbar></div>
    
    <ul v-scrollbar></ul>
    
    <textarea v-scrollbar></textarea>
  5. And voila, you have OverlayScrollbars in Vue, the most easy way.

OverlayScrollbars options

Just pass it with the directive:

<template>
  <div :v-scrollbar="options"></div>
</template>

<script>
  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.
        }
      };
    }
  };
</script>

Get the instance

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

<template>
  <div :v-scrollbar="options" ref="element"></div>
</template>

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

vue-overlayscrollbars's People

Contributors

enriquebv avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.