Releases: p333ter/react-scroll-trigger
Releases · p333ter/react-scroll-trigger
v1.0.1
First release
Release Notes
Version 1.0.0
New Features
- ScrollTrigger Component: A modern React component for monitoring scroll events and triggering callbacks when elements enter, exit, or progress through the viewport.
Improvements
- TypeScript Support: Enhanced type safety and modern React practices.
- Performance Optimization: Throttled scroll and resize event handling for optimized performance.
Bug Fixes
- Intersection Observer Mock: Added mock for
IntersectionObserver
in tests to ensure consistent test results.
Documentation
- README: Comprehensive usage examples and prop descriptions.
- Demo: Example application demonstrating the usage of
ScrollTrigger
component.
Installation
npm install @ppasmik/react-scroll-trigger
or via Yarn:
yarn add @ppasmik/react-scroll-trigger
Usage
import ScrollTrigger from '@ppasmik/react-scroll-trigger';
const MyComponent = () => {
const [visible, setVisible] = useState(false);
const onEnterViewport = () => {
setVisible(true);
};
const onExitViewport = () => {
setVisible(false);
};
return (
<ScrollTrigger onEnter={onEnterViewport} onExit={onExitViewport}>
<div className={`container ${visible ? 'container-animate' : ''}`} />
</ScrollTrigger>
);
};
For more details, refer to the README.md file.