
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
intersection-observer-utility
Advanced tools
This plugin observes elements and sets data attributes accordingly to the state. Also, it emits a custom event every time the element comes into the viewport or leaves the viewport.
A simple Demo can be found on codepen: https://codepen.io/cojaco/pen/rNOmPoK
npm i intersection-observer-utility --save
And in your js
import Iou from 'intersection-observer-utility'
document.addEventListener('DOMContentLoaded', () => {
const myIouInstance = new Iou();
// initialize
myIouInstance.init();
});
Just grab the file https://github.com/nico-jacobs/intersection-observer-utility/blob/master/dist/iou.js
and load it before body end tag e.g.
<script src="yourDomain.com/js/iou.js"></script>
than you can initilize it like:
<script>
document.addEventListener('DOMContentLoaded', function () {
// create instance of the plugin
var myIouInstance = new Iou();
// initialize
myIouInstance.init();
});
</script>
If your Plugin is initialized, you need to add a selector to all the HTML elements that you want to observe. The Default selector for that is the data attribute data-iou-trigger.
The plugin then will attach the data attributes accordingly to the position to the viewport.
| Data Attribute | Default | Options | Description |
|---|---|---|---|
| data-iou-trigger | empty | none | Mandetory selector for the elements that should be observed |
| data-iou-target | not set | any selector you want | Optional, this data attribute holds an Selector of elements that should be triggerd |
| data-iou-relation | set by the plugin | prev, next, current | Marks currently triggered elements, and also marks sibling elements as previous or next |
| data-iou-visible | set by the plugin | true, fals | Shows if element is in viewport or not |
| data-iou-direction | set by the plugin | visible-top,invisible-top, visible-bottom, invisible-bottom | visible-top = element came from top invisble-top = element left the viewport on the top visible-bottom = element came from bottom invisble-bottom = element left the viewport on the bottom side |
Now you can style the elements, based on their data-attribute values. A Demo will follow soon.
Also, the intersection of elements will emit a custom event on the document, that you can listen to.
Example:
bindListener: () => {
document.addEventListener('iouOut', ({detail}) => {
console.log('iou animated out', detail.entryObj.target.targetEls, detail.entryObj);
});
document.addEventListener('iouIn', ({detail}) => {
console.log('iou animated in', detail.entryObj.target.targetEls, detail.entryObj);
});
},
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
I use SemVer for versioning. For the versions available, see the tags on this repository.
Nico Jacobs
This project is licensed under the MIT License - see the LICENSE.md file for details
This Plugin was inspired by AOS Animate On Scroll Library
FAQs
VanillaJS plugin Intersection observer utility
We found that intersection-observer-utility 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.