npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

perfect-scrollbar-react

v1.0.1

Published

A wrapper for perfect-scrollbar to React Component

Downloads

1,108

Readme

PERFECT-SCROLLBAR-REACT

A wrapper for perfect-scrollbar to React Component.

NPM version NPM monthly download

Demo

http://perfect-scrollbar-react.surge.sh

Installation

To install the stable version you can use:

$ yarn add perfect-scrollbar-react

Usage (More detail examples)

  • Just only add one custom css to container for keep safe your design layout
import Scrollbar from 'perfect-scrollbar-react';
import 'perfect-scrollbar-react/dist/style.min.css';
.container-data {
  display: flex;
  height: 200px; // optional or max-height: 200px;
}
...
<Scrollbar
  options={{ minScrollbarLength: 50 }}
  innerRef={node => (this.scrollbar = node)}
/>

...
componentDidMount() {
  if (this.scrollbar) {
    this.scrollbar.element.addEventListener('ps-scroll-y', () =>
      console.log('scroll-y')
    );
  }
}
...
  • Switch native scrollbars for mobile devices
const isMobile = condition && condition;

<Scrollbar enable={!isMobile} />;

Examples

Original code:

...
render() {
  return
  <div className="App">
    <div className="list-data">
      {Array(20)
        .fill(1)
        .map((value, index) => <div key={index}>{value + index}</div>)}
    </div>
  </div>
}
...

Sample 1: (Add custom css to container)

  import Scrollbar from 'perfect-scrollbar-react';

  ...
  render() {
    return
    <div className="App">

      <div
        className="list-data"
        style={{ display: 'flex', maxHeight: '200px' }}
      >
        <Scrollbar>
          {[...Array(20)
            .keys()]
            .map((value, index) => <div key={index}>{value + index}</div>)}
        </Scrollbar>
      </div>

    </div>
  }
  ...

Sample 2: (Create a new container)

  import Scrollbar from 'perfect-scrollbar-react';

  ...
  render() {
    return
    <div className="App">

      <div style={{ display: 'flex', maxHeight: '200px' }}>
        <Scrollbar>
          <div className="list-data">
            {[...Array(20)
              .keys()]
              .map((value, index) => <div key={index}>{value + index}</div>)}
          </div>
        </Scrollbar>
      </div>

    </div>
  }
  ...

Sample 3: (Wrong way)

  import Scrollbar from 'perfect-scrollbar-react';

  ...
  render() {
    return
    <div className="App">

      <div className="list-data">
        <Scrollbar>
          {[...Array(20)
            .keys()]
            .map((value, index) => <div key={index}>{value + index}</div>)}
        </Scrollbar>
      </div>

    </div>
  }
  ...

License

MIT © Nghiệp