BKWLD / vue-in-viewport-directive

Vue 2 directive that adds css classes when the element is the viewport
https://bkwld.github.io/vue-in-viewport-directive
MIT License
120 stars 7 forks source link
directive intersectionobserver viewport vue

Vue In Viewport Directive Build Status

Vue 2 directive that sets CSS classes on its host element based on the elements current position in the viewport. These classes are:

You may want to check out the mixin version of this package: vue-in-viewport-mixin.

Demo: https://bkwld.github.io/vue-in-viewport-directive

Usage

Note, this should not be applied to elements / components that are setting a dynamic class through Vue. See this issue.

Global methods

You can disable all updates and re-enable them globally:

import { enable, disable } from 'vue-in-viewport-directive'
disable()
setTimeout(enable, 500)

This can be used during full page transitions to trigger all the in viewport transitions only once the page transition finishes.

Arguments

Modifiers

Value

Tests

  1. Start Storybook: yarn storybook
  2. Open Cypress: yarn cypress open

The Travis tests that run on deploy run against the demo site which gets updated as part of the npm version