Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scrollmonitor-react

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scrollmonitor-react

React HOC for the scrollMonitor

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
136
decreased by-32%
Maintainers
1
Weekly downloads
 
Created
Source

React-ScrollMonitor

This is a React component that provides an API to the scrollMonitor.

It can call methods when a watched element enters or exits the viewport and adds isInViewport, isAboveViewport, isBelowViewport, and isFullyInViewport to this.props.

Usage

Include it in your project

npm install react-scrollmonitor

Then use it to wrap your own component.

import React from 'react';
import Watch from 'react-scrollmonitor';

export default Watch(class MyComponent extends React.Component {
	render () {
		var text;
		if (this.props.isInViewport) {
			text = 'I AM in the viewport!';
		} else {
			text = 'You will never see this because it gets replaced when it enters the viewport.'
		}

		return (<span>{text}</span>);
	}
});

You can also pass methods with the scrollMonitor event names as props to your component.

import React from 'react';

import MyComponent from './the/example/above';

export default MyParentComponent extends React.Component {
	
	receiveStateChange (watcher) {
		console.log('state changed!', watcher)
	}

	render () {
		return (<MyComponent stateChange={this.receiveStateChange} />)
	}
}

Keywords

FAQs

Package last updated on 01 Nov 2016

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc