New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-inview-js

Package Overview
Dependencies
Maintainers
2
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-inview-js

React Inview checker with only javascript

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
44
decreased by-54.64%
Maintainers
2
Weekly downloads
 
Created
Source

React Inview

Checks if component is inview. Built with vanilla javascript.

Currently in beta, please help contribute! Screenshot

Installation

Requires nodejs.

npm install react-inview-js

Options

  • showGuides: creates visual indicator of viewport size
  • offsetY: range 0 to 1. changes how large the viewport should be. Defaults to 0 which is the full size of browser.
  • fullElementInView: boolean(true/false) - false means just the top of the element is in view - good for large elements

Received Props

  • this.props.elementIsInView: True/false value based on if element is in view
  • this.props.elementHasBeenInView: True/false if the element has been in view

How To Use

import React, { Component } from 'react';
import ReactInview from 'react-inview-js';

class MyComponent extends Component {

 render () {
    const inView = this.props.elementIsInView;
    const elementHasBeenInView = this.props.elementHasBeenInView;

    // Change classname based on boolean
    const viewClassName = (inView)? 'is--inview-true' : 'is--inview-false';
    const elementHasBeenInView = (elementHasBeenInView)? 'Element has been seen' : 'Element has not been in view';

    return (
      <article className={viewClassName}>
        <h1>React InView -- { elementHasBeenInView }</h1>
      </article>
    );
  }
}

const InviewOptions = {offsetY: 0.8, showGuides: true, fullElementInView: false}

export default ReactInview(InviewOptions)(MyComponent);

Example

npm install && npm install react react-dom && npm start

Keywords

FAQs

Package last updated on 04 Jan 2018

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