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

react-scroll

Package Overview
Dependencies
Maintainers
1
Versions
118
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-scroll

A scroll component for React.js

  • 1.3.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
396K
decreased by-15.37%
Maintainers
1
Weekly downloads
 
Created

What is react-scroll?

The react-scroll package provides smooth scrolling functionality for React applications. It allows developers to create scrollable components and implement smooth scrolling animations to specific elements within a page.

What are react-scroll's main functionalities?

Smooth Scrolling to Elements

This feature allows you to create links that smoothly scroll to specific elements on the page. The 'Link' component is used to create the scrollable link, and the 'Element' component is used to define the target section.

import { Link, Element } from 'react-scroll';

function App() {
  return (
    <div>
      <Link to="section1" smooth={true} duration={500}>Go to Section 1</Link>
      <Element name="section1" className="element">
        Section 1
      </Element>
    </div>
  );
}

Scroll Events

This feature allows you to register and handle scroll events. You can log or perform actions when scrolling begins or ends. The 'animateScroll' function can be used to programmatically scroll to specific positions.

import { Events, animateScroll as scroll, scroller } from 'react-scroll';

function App() {
  useEffect(() => {
    Events.scrollEvent.register('begin', function() {
      console.log('begin', arguments);
    });

    Events.scrollEvent.register('end', function() {
      console.log('end', arguments);
    });

    return () => {
      Events.scrollEvent.remove('begin');
      Events.scrollEvent.remove('end');
    };
  }, []);

  return (
    <div>
      <button onClick={() => scroll.scrollToTop()}>Scroll to Top</button>
    </div>
  );
}

Scroll to Top

This feature provides a simple way to scroll to the top of the page programmatically. The 'scrollToTop' function from 'animateScroll' is used to achieve this.

import { animateScroll as scroll } from 'react-scroll';

function App() {
  return (
    <div>
      <button onClick={() => scroll.scrollToTop()}>Scroll to Top</button>
    </div>
  );
}

Other packages similar to react-scroll

Keywords

FAQs

Package last updated on 27 Aug 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