Vue plugin for detecting when elements enter and leave the viewport
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.gitignore Initial commit Jun 26, 2014
LICENSE Initial commit Jun 26, 2014
gulpfile.js Initial commit Jun 26, 2014

Viewport plugin for Vue

This Vue plugin adds a detect-viewport directive, allowing you to detect viewport enter and leave events in your VM.


Follow the official Vue plugin documentation for installation instructions.

Once the plugin is added to your project, you can add a v-detect-viewport attribute to any VM element and then listen to viewportenter and viewportleave events.

<div v-component="my-component" v-detect-viewport>
	<p>Am I in the viewport?</p>
Vue.component('my-component', {
	created: function () {
		this.$on('viewportenter', function () {
			console.log('I have entered the viewport.')
		this.$on('viewportleave', function () {
			console.log('I have left the viewport.')