vue-scroll-class

A Vue directive to easily add and remove a class from an element when the screen is scrolled past a given point
62,144 6
Install
npm install vue-scroll-class
Latest Version:1.2.3
Vue:2
License:MIT
Last Updated:Aug 30, 2017
Links: GitHub  ·  npm
Maintainer: jasepellerin

vue-scroll-class

A Vue.js directive to add a class to an based on vertical scroll.

Installation

npm i -S vue-scroll-class

Import

import VueScrollClass from 'vue-scroll-class';

Add to Vue

Register to Vue globally:

Vue.directives('scroll-class': VueScrollClass);

Register to a specific Vue instance:

  const app = new Vue({
  ...
  directives: {
    'scroll-class': VueScrollClass,
  },
  ...
});

Usage

vue-scroll-class defaults to adding the class 'sticky' to the attached element after the page has been scrolled 100px:

<div v-scroll-class>I'll get the class 'sticky' after 100px!</div>

To override these defaults, add a class name or a different number of pixels in the appropriate place:

<div v-scroll-class:differentClass=645>I'll get the class 'differentClass' after 645px!></div>

Related Packages

vue-sticky-directive

A powerful vue directive make element sticky.

256,646 169
vue3-sticky-directive

Vue3-sticky-directive is a powerful Vue 3 directive make element sticky. This is...

75,838 4
vue-lazysizes

If you use Lazysizes this vue-directive updates img element if src attribute is...

11,786
vue-auto-resize

A Vue directive to auto resize the height of a textarea to its contents as you t...

2,490 7
vue-lazyload

Vue module for lazy-loading images in your vue.js applications.

2,917,864 7,978

Version History

Version Released License
1.2.3 MIT
1.2.2 MIT
1.2.1 MIT
1.2.0 MIT
1.1.1 MIT
Pre-releases (5)
Version Released License
1.2.3-alpha1 MIT
1.2.2-alpha1 MIT
1.1.1-alpha1 MIT
1.0.8-alpha2 MIT
1.0.8-alpha1 MIT