JSPM

  • Created
  • Published
  • Downloads 2290
  • Score
    100M100P100Q113512F
  • License MIT

A simple interface for scrollytelling using IntersectionObserver.

Package Exports

  • react-scrollama

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-scrollama) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-scrollama

React Scrollama is a simple interface for scrollytelling. It uses IntersectionObserver in favor of scroll events, and is largely based off of Russel Goldenberg's Scrollama library.

Installation

React Scrollama can be installed as an npm package:

$ npm install react-scrollama

Basic Usage

import React, { PureComponent } from 'react';
import { Scrollama, Step } from 'react-scrollama';

class Example extends PureComponent {
  state = {
    data: 0,
  };
  
  onStepEnter = ({ element, data, direction }) => this.setState({ data });
  
  render() {
    const { data } = this.state;
    
    return (
      <div>
        <p>data: {data}</p>
        <Scrollama onStepEnter={this.onStepEnter}>
          <Step datum={1}>
            <p>step 1</p>
          </Step>
          <Step datum={2}>
            <p>step 2</p>
          </Step>
        </Scrollama>
      </div>      
    );
  }
}