@surveyplanet/in_view

1.0.1 • Public • Published

In View

Check whether and element is within the browser viewport.

Install

npm install --save @surveyplanet/in-view

Example

import inView from 'in_view';

const target = document.getElementById('target', {});

document.addEventListener('scroll', (e) => {

  let isInView = inView(target, scrollOptions); \\ ture or flase
  console.log('element is in view:', isInView );

});

Options

Returns: Boolean - Whether the element is inside the document viewport or not.

Param Type Description
element HTMLElement | String An HTMLElement or String containing a valid id (#my-elm) or class.(.my-elm) name
options Object function options.
options.partial Boolean When true the element is considered inside the viewport if any part is visible.
options.offset Number | String Offset the element either by number of pixels or a percentage e.g.:'50%'

Testing

npm install
npm test

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    2

Package Sidebar

Install

npm i @surveyplanet/in_view

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

8.91 kB

Total Files

8

Last publish

Collaborators

  • serferdinand2
  • jwerre
  • jw310