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

react-waypoint

Package Overview
Dependencies
Maintainers
4
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-waypoint

A React component to execute a function whenever you scroll to an element.

  • 8.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
230K
decreased by-14.7%
Maintainers
4
Weekly downloads
 
Created

What is react-waypoint?

The react-waypoint package allows you to execute a function whenever you scroll to an element. It is useful for lazy loading images, infinite scroll, or triggering animations when elements come into view.

What are react-waypoint's main functionalities?

Basic Waypoint

This code demonstrates a basic usage of the Waypoint component. When the user scrolls to the waypoint, the onEnter function is triggered, logging a message to the console.


import React from 'react';
import Waypoint from 'react-waypoint';

const MyComponent = () => (
  <div>
    <Waypoint
      onEnter={() => console.log('Waypoint entered!')}
    />
    <div style={{ height: '100vh' }}>
      Scroll down to trigger the waypoint.
    </div>
  </div>
);

export default MyComponent;

Waypoint with Offset

This example shows how to use the topOffset prop to trigger the waypoint when it is 50% from the top of the viewport.


import React from 'react';
import Waypoint from 'react-waypoint';

const MyComponent = () => (
  <div>
    <Waypoint
      onEnter={() => console.log('Waypoint entered!')}
      topOffset='50%'
    />
    <div style={{ height: '100vh' }}>
      Scroll down to trigger the waypoint.
    </div>
  </div>
);

export default MyComponent;

Waypoint with Children

This example demonstrates how to wrap a child component with the Waypoint component. The onEnter function will be triggered when the child component comes into view.


import React from 'react';
import Waypoint from 'react-waypoint';

const MyComponent = () => (
  <div>
    <Waypoint
      onEnter={() => console.log('Waypoint entered!')}
    >
      <div style={{ height: '100vh' }}>
        Scroll down to trigger the waypoint.
      </div>
    </Waypoint>
  </div>
);

export default MyComponent;

Other packages similar to react-waypoint

Keywords

FAQs

Package last updated on 18 Jun 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