Skip to content

Tracks element visibility relative to its scrolling parent

Notifications You must be signed in to change notification settings

Tolkam-JS-Packages/lib-in-view

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tolkam/lib-in-view

Tracks element visibility relative to its scrolling parent.

Usage

import InView, { IVisibility } from '@tolkam/lib-in-view';

const elementToTrack = document.getElementById('trackMe')!;

const inView = new InView(elementToTrack, (visibility: IVisibility) => {
    if(visibility.rendered && visibility.visible) {
        console.log("I'm visible!");
        inView.stop();
    }
});

Documentation

The code is rather self-explanatory and API is intended to be as simple as possible. Please, read the sources/Docblock if you have any questions. See Usage for quick start.

License

Proprietary / Unlicensed 🤷

About

Tracks element visibility relative to its scrolling parent

Resources

Stars

Watchers

Forks

Packages

No packages published