All Projects â†’ ryanhefner â†’ react-scroll-trigger

ryanhefner / react-scroll-trigger

Licence: MIT license
📜 React component that monitors scroll events to trigger callbacks when it enters, exits and progresses through the viewport. All callback include the progress and velocity of the scrolling, in the event you want to manipulate stuff based on those values.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-scroll-trigger

onscroll-effect
A tiny JavaScript library to enable CSS animations when user scrolls.
Stars: ✭ 35 (-72.22%)
Mutual labels:  scrolling, scroll, viewport
Stickyfill
Polyfill for CSS `position: sticky`
Stars: ✭ 2,252 (+1687.3%)
Mutual labels:  scrolling, scroll
React Indiana Drag Scroll
React component which implements scrolling via holding the mouse button or touch
Stars: ✭ 190 (+50.79%)
Mutual labels:  scrolling, scroll
Moveto
A lightweight scroll animation javascript library without any dependency
Stars: ✭ 2,746 (+2079.37%)
Mutual labels:  scrolling, scroll
Scroll Js
Light cross-browser scroller that uses native javascript
Stars: ✭ 179 (+42.06%)
Mutual labels:  scrolling, scroll
Infinitescroll
Infinite Scroll (Endless Scrolling) for RecyclerView in Android
Stars: ✭ 183 (+45.24%)
Mutual labels:  scrolling, scroll
Scrollstory
A jQuery plugin for building scroll-based stories
Stars: ✭ 249 (+97.62%)
Mutual labels:  scrolling, trigger
Jquery Scrolllock
Locks mouse wheel scroll inside container, preventing it from propagating to parent element
Stars: ✭ 109 (-13.49%)
Mutual labels:  scrolling, scroll
React Horizontal Scrolling Menu
Horizontal scrolling menu component for React.
Stars: ✭ 289 (+129.37%)
Mutual labels:  react-component, scroll
React Scrollbars Custom
The best React custom scrollbars component
Stars: ✭ 576 (+357.14%)
Mutual labels:  react-component, scroll
react-is-scrolling
Simply detect if users are scrolling in your components in a declarative API
Stars: ✭ 17 (-86.51%)
Mutual labels:  scrolling, scroll
Horizontal Scroll
Horizontal scroll with inertia
Stars: ✭ 175 (+38.89%)
Mutual labels:  scrolling, scroll
React Intersection Observer
React implementation of the Intersection Observer API to tell you when an element enters or leaves the viewport.
Stars: ✭ 2,689 (+2034.13%)
Mutual labels:  scrolling, viewport
Scroll Snap
↯ Snap page when user stops scrolling, with a customizable configuration and a consistent cross browser behaviour
Stars: ✭ 187 (+48.41%)
Mutual labels:  scrolling, scroll
Ngx Ui Scroll
Infinite/virtual scroll for Angular
Stars: ✭ 145 (+15.08%)
Mutual labels:  scrolling, scroll
V Bar
The virtual responsive crossbrowser scrollbar component for VueJS 2x
Stars: ✭ 216 (+71.43%)
Mutual labels:  scrolling, scroll
scroll-sync-react
A scroll syncing library for react that is up to date
Stars: ✭ 49 (-61.11%)
Mutual labels:  scrolling, scroll
Pd Select
vue components ,like ios 3D picker style,vue 3d 选择器组件,3D滚轮
Stars: ✭ 101 (-19.84%)
Mutual labels:  scrolling, scroll
Prognroll
A tiny, lightweight jQuery plugin that creates scroll progress bar on the page.
Stars: ✭ 108 (-14.29%)
Mutual labels:  scrolling, scroll
react-recycled-scrolling
Simulate normal scrolling by using only fixed number of DOM elements for large lists of items with React Hooks
Stars: ✭ 26 (-79.37%)
Mutual labels:  react-component, scrolling

📜 react-scroll-trigger

npm NPM npm Coveralls github CircleCI Snyk Vulnerabilities for GitHub Repo

React component that monitors scroll events to trigger callbacks when it enters, exits and progresses through the viewport. All callback include the progress and velocity of the scrolling, in the event you want to manipulate stuff based on those values.

Install

Via npm

npm install react-scroll-trigger

Via Yarn

yarn add react-scroll-trigger

How to use

import ScrollTrigger from 'react-scroll-trigger';

...

  onEnterViewport() {
    this.setState({
      visible: true,
    });
  }

  onExitViewport() {
    this.setState({
      visible: false,
    });
  }

  render() {
    const {
      visible,
    } = this.state;

    return (
      <ScrollTrigger onEnter={this.onEnterViewport} onExit={this.onExitViewport}>
        <div className={`container ${visible ? 'container-animate' : ''}`} />
      </ScrollTrigger>
    );
  }

The ScrollTrigger is intended to be used as a composable element, allowing you to either use it standalone within a page (ie. no children).

  <ScrollTrigger onEnter={this.onEnterViewport} onExit={this.onExitViewport} />

Or, pass in children to receive events and progress based on the dimensions of those elements within the DOM.

  <ScrollTrigger onEnter={this.onEnterViewport} onExit={this.onExitViewport}>
    <List>
      [...list items...]
    </List>
  </ScrollTrigger>

The beauty of this component is its flexibility. I’ve used it to trigger AJAX requests based on either the onEnter or progress of the component within the viewport. Or, as a way to control animations or other transitions that you would like to either trigger when visible in the viewport or based on the exact progress of that element as it transitions through the viewport.

Properties

Below are the properties that can be defined on a <ScrollTrigger /> instance. In addition to these properties, all other standard React properites like className, key, etc. can be passed in as well and will be applied to the <div> that will be rendered by the ScrollTrigger.

  • component:Element | String - React component or HTMLElement to render as the wrapper for the ScrollTrigger (Default: div)
  • containerRef:Object | String - DOM element instance or string to use for query selecting DOM element. (Default: document.documentElement)
  • throttleResize:Number - Delay to throttle resize calls in milliseconds (Default: 100)
  • throttleScroll:Number - Delay to throttle scroll calls in milliseconds (Default: 100)
  • triggerOnLoad:Boolean - Whether or not to trigger the onEnter callback on mount (Default: true)
  • onEnter:Function - Called when the component enters the viewport ({progress, velocity}, ref) => {}
  • onExit:Function - Called when the component exits the viewport ({progress, velocity}, ref) => {}
  • onProgress:Function - Called while the component progresses through the viewport ({progress, velocity}, ref) => {}

License

MIT © Ryan Hefner

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].