
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
vue-intersect
Advanced tools
A Vue component to add intersection-observer to a Vue component or HTML element.
A Vue component to add intersection observe a Vue component or HTML element.
The IntersectionObserver is an amazing API which allows you to observe one or more HTMLElement for when it has enterede or left the viewport.
This API has many use cases like, infinite-scroll, lazy-loading or animations when an element enters the viewport.
Simply install using your favorite package manager 🔥
npm install vue-intersect --save
yarn add vue-intersect
The package acts as an abstract component, much like what you may know from keep-alive or transition.
This means that it's basically a "decorator". A component which does not output any markup to the DOM, but adds the functionality under the hood 😱.
<template>
<intersect @intersected="msg = 'Intersected!'">
<div>{{ msg }}</div>
</intersect>
</template>
<script>
import Intersect from 'vue-intersect'
export default {
components: { Intersect },
data () {
return {
msg: 'Not intersected.'
}
},
methods: {
onIntersected () {
alert('Element has intersected.')
}
}
}
</script>
Property | Type | Default | Required | Description |
---|---|---|---|---|
threshold | Array | [0.2] | no | MDN docs |
root | HTMLElement | null | no | MDN docs |
rootMargin | String | 0px 0px 0px 0px | no | MDN docs |
Name | Arguments | Description |
---|---|---|
intersected | none | Event fired on intersected. |
The IntersectionObserver API is not currently available in all browsers (IE11, Safari and iOS Safari). If you intend to support these browsers, you'll need to add a poylfill to your bundle.
WICG IntersectionObserver Polyfill is higly recommended.
FAQs
A Vue component to add intersection-observer to a Vue component or HTML element.
The npm package vue-intersect receives a total of 2,225 weekly downloads. As such, vue-intersect popularity was classified as popular.
We found that vue-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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.