Socket
Book a DemoInstallSign in
Socket

react-view-tracker

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-view-tracker

[![npm package][npm-badge]][npm] ![Module formats][module-formats]

0.1.1
latest
Source
npmnpm
Version published
Weekly downloads
5
150%
Maintainers
1
Weekly downloads
 
Created
Source

React View Tracker

npm package Module formats

Simple react component that watch element when enters or leaves the browser viewport.

Demo

Installation

Add react-view-tracker dependency

yarn add react-view-tracker
npm install react-view-tracker --save

Usage

import ViewTracker from 'react-view-tracker'
<ViewTracker
  onShow={(entry)=> {console.log(entry)})}
>
  <Content />
</ViewTracker>

Options

NameTypeDefaultRequiredDescription
onShowFunctionnullfalseWhen element visible in the view port this function will be called with entry.
onHideFunctionnullfalseWhen element visible then not visible in the view port this function will be called with entry
onStartObservingFunctionnullfalseWhen component did load it will start observing and call this function with container element
onStopObservingFunctionnullfalseWhen component un mount it will stop observing and call this function with container element
setRootContainerFunctionnullfalseThe Function should return Element that is used as the viewport for checking visibility of the target.
oncebooleanfalsefalseOnly trigger this method once
visiblePercentagenumber | number[]1falseNumber between 0 and 1 indicating the percentage that should be visible before triggering. Can also be an array of numbers, to create multiple trigger points.
offsetobject{left: 0, right: 0, top: 0, bottom: 0}falseMargin around the root.

License

This project is licensed under the MIT License - see the LICENCE.md file for details

Keywords

react

FAQs

Package last updated on 25 Jan 2020

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.