1.0.3 • Published 2 years ago

react-flicker-scroll v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

React Flicker Scroll

A React component that detects when it is in the center of the viewport and can change styling while centered.

Demo: https://marcellmueller.github.io/react-flicker-scroll/

Installation

npm i react-flicker-scroll

or

yarn add react-flicker-scroll

Usage

Use the FlickerScroll component to wrap your content. Active styles can be customized by using the activeStyles prop as shown.

You can technically put any type children inside the FlickerScroll component though only the basic activeStyles css is supported.

onFlickerOn and onFlickerOff props take a function that runs as the component scroll in and out of the center of the viewport.

stayActive prop accepts a boolean value and will keep the active state regardless of scroll position when true.

import { FlickerScroll } from 'react-flicker-scroll';
import styles from './Basic.module.css';

const text = [
  'React',
  'Flicker',
  'Scroll',
  'package',
  'by',
  'Marcel',
  'Mueller',
];

const Example = () => {
  return (
    <div>
      {text.map((line, i) => {
        return (
          <FlickerScroll
            key={i}
            activeStyles={{
              color: 'red',
            }}
            className={styles.flicker}
            onFlickerOn={() => console.log('flicker on')}
            onFlickerOff={() => console.log('flicker off')}
            stayActive={line === 'React'}
          >
            {line}
          </FlickerScroll>
        );
      })}
    </div>
  );
};

export default Example;

Dependencies

srraf to monitor scrolling https://github.com/estrattonbailey/srraf

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.12.0

2 years ago

0.11.0

2 years ago

0.10.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago