react over-scroll
yarn add react-over-scroll
Description
OverScroll is a slide-show or content-slider, call it what you want. It is a full-screen/viewport element that snaps into fixed mode when it reaches the viewports top edge. Scrolling is now translated to paging, switching the content each time a predefined scroll amount has been reached. During an active slide two values are available. (See Render for more information). Take a look at the Demo to get a better understanding of the behavior.
Render
OverScroll allows the usage of a child function or a render property.
Example 1
import React from "react";import OverScroll from "react-over-scroll"; const Example = <OverScroll => page progress <div> <ul> <li>progress: progress</li> <li>page: page</li> </ul> </div> </OverScroll>;
Example 2
import React from "react";import OverScroll from "react-over-scroll"; const renderPages = page progress <div> <ul> <li>progress: progress</li> <li>page: page</li> </ul> </div>; const Example = <OverScroll = = />;
Configuration
anchors: ?string
: Use anchors to allow deep-links and browser history.factor: ?number
: Change the factor that translates scroll offset to progress.slides: number
: The number of pages. Each page has its own progress scope.
import React from "react";import OverScroll from "react-over-scroll"; const Example = <OverScroll = ="!/example" > page progress anchors <div> <ul> <li>progress: progress</li> <li>page: page</li> </ul> </div> </OverScroll>;
Advanced
Listener
You can import a listener to build plugins. Listener
is only active if a child function is used.
import React from "react";import OverScroll Listener from "react-over-scroll"; const MyPlugin = <Listener> page progress <div> <ul> <li>progress: progress</li> <li>page: page</li> </ul> </div> </Listener>; const Example = <OverScroll => <MyPlugin /></OverScroll>;
progressable
Overscroll provides a helper to add a progress variable to your component.
import React from "react";import OverScroll progressable Listener from "react-over-scroll";import styled from "styled-components"; const Box = styleddiv` height: 1rem; width: calc(var(--progress, 0) * 100%; background: currentColor;` // Using Listenerconst ProgressBar = <Listener> progress ) </Listener>;// Usage// <ProgressBar/> // Using properties// const ProgressBar = ({progress}) => progressable(<Box/>, progress));// Usage// <ProgressBar progress={progress}/> const Example = <OverScroll => page progress <div> <ul> <li>progress: progress</li> <li>page: page</li> <ProgressBar/> </ul> </div> </OverScroll>;
Styled elements
Overscroll provides a wrapper and pagers.
import React from "react";import ThemeProvider from "styled-components";import OverScroll Listener from "react-over-scroll";import Inner Pagers themes from "react-over-scroll/lib/src/styled"; const Example = <OverScroll = ="!/example"> <ThemeProvider => <Inner => <Pagers = /> <ul> <li>progress: contextprogress</li> <li>page: contextpage</li> </ul> </Inner> </ThemeProvider> </OverScroll>;
Development
If you want to build this module from source or contribute to this project you should follow the steps listed below.
Setup
yarn
Run dev server
yarn dev --hot
For more options take a look at the package.json
for this project.
Copyright © 2018 - Gregor Adams