Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.
/ vue-viewport Public archive

Vue plugin for detecting when elements enter and leave the viewport

License

Notifications You must be signed in to change notification settings

holic/vue-viewport

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Viewport plugin for Vue

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

Usage

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>
</div>
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.')
		})
	}
})

About

Vue plugin for detecting when elements enter and leave the viewport

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages