in-view-ts
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

in-view.ts 👀

fork by: https://github.com/camwiegert/in-view


Installation

npm install --save in-view-ts

Basic Usage

With in-view-ts, you can register handlers that are called when an element enters or exits the viewport. Each handler receives one element, the one entering or exiting the viewport, as its only argument.

// watch window scroll
const inview = new InView();
inview.control(document.getElementById('#target')).registry
    .on('enter', (element) => {
        console.log(element);
    });
// watch parent scroll
const inview = new InView(document.getElementById('#parent'));
inview.control(document.getElementById('#target')).registry
    .on('enter', (element) => {
        console.log(element);
    });
// watch parent scroll
const inview = new InView('#parent');
inview.control('#target').registry
    .on('enter', (element) => {
        console.log(element);
    });

API

see: https://github.com/camwiegert/in-view


License MIT

Readme

Keywords

none

Package Sidebar

Install

npm i in-view-ts

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

290 kB

Total Files

30

Last publish

Collaborators

  • derushio