vue-scrollbox

1.0.1 • Public • Published

vue-scrollbox

A Vue.js (v2.x+) component to provide scroll and observe resize.

Installation

NPM

$ npm install vue-scrollbox --save

import the script:

import VueScrollbox from 'vue-scrollbox';

Script tag

Grab the minified version under dist/vue-scrollbox.min.js It will export a global VueScrollbox variable.

Usage

Register the component globally or locally:

Vue.component('vue-scrollbox', VueScrollbox);

OR

...
components: {
  VueScrollbox
}
...

HTML

<vue-scrollbox mode="vertical" @scroll="onScroll" @resize="onResize">
  <h1>TEST</h1>
  <h1>TEST</h1>
  <h1>TEST</h1>
  <h1>TEST</h1>
</vue-scrollbox>

Props

Name Type Description
mode String Select one of the options: vertical, horizontal, auto. default: vertical
width Number Fix canvas width.
height Number Fix canvas height.

Events

When the user scrolls contents scroll event will be dispatched. When viewport or canvas changed size resize event will be dispatched.

...
methods: {
  onScroll (offset) {
    console.log('onScroll', offset)
  },
  onResize (viewport, canvas) {
    console.log('onResize', viewport, canvas)
  }
}
...

Readme

Keywords

none

Package Sidebar

Install

npm i vue-scrollbox

Weekly Downloads

17

Version

1.0.1

License

MIT

Unpacked Size

22.9 kB

Total Files

4

Last publish

Collaborators

  • john-white-92