Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
v-intersect
Advanced tools
Readme
Detect when element is visible or hidden on user viewport
npm install v-intersect --save
yarn add v-intersect
Install the plugin into your Vue project:
import Vue from 'vue'
import VIntersect from 'v-intersect'
Vue.use(VIntersect)
or use the component and directive directly:
import Vue from 'vue'
import { VIntersectComp, VIntersectDir } from 'v-intersect'
Vue.directive('intersect', VIntersectDir)
Vue.component('v-intersect', VIntersectComp)
<div class="content" v-intersect="onIntersect">...</div>
The function will be called when the visibility of the element is changes.
onIntersect(observer){
this.isVisible = observer.isIntersecting
console.log(observer.entries)
}
isIntersecting
: when it's true
it means the element is visible on the screen, and false
means it's hiddenentries
: IntersectionObserverEntryAnd if you want the function only called when element is visible you can use .enter
modifier.
<div class="content" v-intersect.enter="onIntersect">...</div>
<div class="content" v-intersect="{
callback: onIntersect,
options: {
root: ...,
rootMargin: ...,
threshold: ...
}
}">
</div>
For more details IntersectionObserver Options
It will called the function once when the element is visible
<div class="content" v-intersect="{
callback: onIntersect,
once: true
}" />
<div class="content" v-intersect="{
callback: onIntersect,
disabled: true
}" />
<v-intersect @change="onIntersect">
<div class="content">...</div>
</v-intersect>
Name | Description |
---|---|
change | event fired when visibility of the element change |
enter | event fired when the element is intersect (visible) on the screen |
once | event fired once when the elemnt is visible |
Name | Type | Default | Description |
---|---|---|---|
root | String | ' ' | MDN |
rootMargin | String | '0px' | MDN |
threshold | [Array, Number] | 0 | MDN |
disabled | Boolean | false | Disable the observer |
Note: for root
prop, you need to pass the element class or id i.e .content
or #content
This plugin uses The IntersectionObserver API, and currently it is not available in all browsers (IE11, Safari and iOS Safari). If you intend to support these browsers, you can include WICG IntersectionObserver Polyfill to your bundle.
FAQs
Detect when element is visible or hidden on user viewport
The npm package v-intersect receives a total of 114 weekly downloads. As such, v-intersect popularity was classified as not popular.
We found that v-intersect demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.