
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
vue-element-spy
Advanced tools
Vue.js plugin for detecting when element reaches top of the viewport. The plugin uses Intersection Observer.
Plugin for detecting when element reaches top of the viewport. The plugin uses Intersection Observer.
yarn add vue-element-spy
import Vue from 'vue'
import VueElementSpy from 'vue-element-spy'
Vue.use(VueElementSpy)
<script src="vue.js"></script>
<script src="/node_modules/vue-element-spy/dist/vue-element-spy.js"></script>
Vue.use(VueElementSpy)
It's possible to set refreshInterval option for periodical spies refresh. Use if content changes or reflows without scrolling.
Default: 250
Disable: 0
Vue.use(VueElementSpy, {refreshInterval: 500})
v-vue-element-spy observes whether the target element is at the top of the viewport and calls callback.
Beware that v-vue-element-spy has a side effect - an empty div element is appended before the spied element. The reason is that a target element may be bigger then the viewport that's why expected intersection 100% isn't possible and IntersectionObserver will remain silent.
<div v-vue-element-spy="{callback: myCallback}">
<!-- or shortened syntax -->
<div v-vue-element-spy="myCallback">
Callback function. Two arguments are passed: boolean whether element is reached top, target element.
Set watchExit to true if you want to observe bottom of the target and get notified when the whole element leaves viewport.
Default: false
Set offset value if you want to move activation point in px.
Default: 0
By default all spies are in one global context and if second target reaches viewport then first target becomes inactive.
Set context to false if you don't want the target to be affected by other spies.
Set context to any String values to define separate context for a target.
Default: true
Set shouldSpy if you want to conditionally activate/deactivate the spy.
Default: true
<div>
  <h1 v-vue-element-spy="{myCallback, context: 'titles'}">Title 1</h1>
  <h1 v-vue-element-spy="{myCallback, context: 'titles'}">Title 2</h1>
  <h1 v-vue-element-spy="{myCallback, context: 'titles'}">Title 3</h1>
</div>
FAQs
Vue.js plugin for detecting when element reaches top of the viewport. The plugin uses Intersection Observer.
We found that vue-element-spy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.