@ifake/page-visibility
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

Welcome to @ifake/page-visibility 👋

Wrapper for the Page Visibility API.

The scaffolding for this project is from pkg

🏠 Homepage

Document

WIP

Usage

# Make sure you have yarn installed on your machine.
yarn add @ifake/page-visibility
# or
npm install @ifake/page-visibility
  • Browser
// We expose a global variable that can be used directly in the browser.
const IFPageVisible = window.IFPageVisible
  • ES6 Module
import { pageVisibility } from '@ifake/page-visibility'
pageVisibility.observe(isVisible => {
  if (isVisible) {
    // Page show do something
    console.log("Page show")
  } else {
    // Page hide do something
    console.log("Page show")
  }
})

// cancel listen
pageVisibility.unobserve()

API

WIP

TODO

  • [ ] Add blur & focus events for browsers that don't support the API or for users who have special needs

Author

👤 ifake

🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

📝 License

This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator

Package Sidebar

Install

npm i @ifake/page-visibility

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

12.4 kB

Total Files

9

Last publish

Collaborators

  • loadingmore