1.2.0 • Published 4 years ago

scroll-to-component v1.2.0

Weekly downloads
17
License
MIT
Repository
github
Last release
4 years ago

scroll-to-component

A React component to warp the aim component, and afford a scrollIntoView method to scroll aim component to visible area.

Install

npm install scroll-to-component
or
yarn add scroll-to-component

Usage

import React, { useRef } from 'react';
import ScrollToComponent from 'scroll-to-component';

export default () => {
  const demo = useRef();

  const scroll = () => {
    const param = { behavior: 'smooth' };
    demo.current.scrollIntoView(param);
  };

  return (
    <ScrollToComponent ref={demo}>
      <YourComponent />
    </ScrollToComponent>
  );
};

The param is same as origin scrollIntoView in DOM element. Regard as MDN.

1.2.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago