• This repository has been archived on 11/Apr/2020
  • Stars
    star
    293
  • Rank 141,748 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 9 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Slider/Carousel powered by React Motion.

⚠️ NO LONGER MAINTAINED

This library is no longer being maintained. Please use framer-motion or another animation library to power your view pagers.

React View Pager

Dependency Status

View-Pager/Slider/Carousel powered by React Motion.

react-motion-slider

Note before using

Use at your own risk, API's are subject to change. It's been fairly stable these last few months, but still might change slightly. Once the outstanding issues are fixed I will release 1.0.0.

Usage

yarn add react-view-pager

npm install react-view-pager --save

<script src="https://unpkg.com/react-view-pager/dist/react-view-pager.js"></script>
(UMD library exposed as `ReactViewPager`)

Example

import { ViewPager, Frame, Track, View } from 'react-view-pager'

<ViewPager tag="main">
  <Frame className="frame">
    <Track
      ref={c => this.track = c}
      viewsToShow={2}
      infinite
      className="track"
    >
      <View className="view">1</View>
      <View className="view">2</View>
      <View className="view">3</View>
      <View className="view">4</View>
    </Track>
  </Frame>
  <nav className="pager-controls">
    <a
      className="pager-control pager-control--prev"
      onClick={() => this.track.prev()}
    >
      Prev
    </a>
    <a
      className="pager-control pager-control--next"
      onClick={() => this.track.next()}
    >
      Next
    </a>
  </nav>
</ViewPager>

ViewPager Props

tag: PropTypes.string

The HTML tag for this element. Defaults to div.

Frame Props

tag: PropTypes.string

The HTML tag for this element. Defaults to div.

autoSize: PropTypes.oneOf([true, false, 'width', 'height'])

Animates the wrapper's width and/or height to fit the current view. Defaults to false.

accessibility: PropTypes.bool

Enable tabbing and keyboard navigation.

springConfig: React.PropTypes.objectOf(React.PropTypes.number)

Accepts a React Motion spring config.

Track Props

tag: PropTypes.string

The HTML tag for this element. Defaults to div.

currentView: PropTypes.any

Specify the index or key of a view to move to that view. Use with onViewChange to control the state of the pager.

viewsToShow: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf(['auto'])])

The number of views visible in the frame at one time. Defaults to 1. Use auto to respect the views's natural or defined dimensions.

viewsToMove: PropTypes.number

The number of views to move upon using prev and next methods. Defaults to 1.

align: PropTypes.number

Pass any number to offset the view from the start of the track. For example, 0 aligns to the start of the track, 0.5 to the center, and 1 aligns to the end.

contain: PropTypes.bool

Prevents empty space from showing in frame. Defaults to false.

infinite: PropTypes.bool

Prepare your pager for intergalactic space travel. Allows the track to wrap to the beginning/end when moving to a view. To infinity and beyond!

instant: PropTypes.bool

Move to a view instantly without any animation. This will control the internal instant state inside of the component.

axis: PropTypes.oneOf(['x', 'y'])

Which axis the track moves on. Defaults to x.

animations: PropTypes.array

Define a limitless array of animation stops. Each object in the array requires a prop and stops property along with an optional unit property.

// scale and fade views as they enter and leave
const animations = [{
  prop: 'scale',
  stops: [
    [-200, 0.85],
    [0, 1],
    [200, 0.85]
  ]
}, {
  prop: 'opacity',
  stops: [
    [-200, 0.15],
    [0, 1],
    [200, 0.15]
  ]
}]

swipe: PropTypes.oneOf([true, false, 'touch', 'mouse'])

Enable touch and/or mouse dragging. Defaults to true.

swipeThreshold: PropTypes.number

The amount the user must swipe to advance views. (frameWidth * swipeThreshold). Defaults to 0.5.

flickTimeout: PropTypes.number

The amount of time in milliseconds that determines if a swipe was a flick or not.

rightToLeft: PropTypes.bool (Coming Soon)

lazyLoad: PropTypes.bool (Coming Soon)

springConfig: React.PropTypes.objectOf(React.PropTypes.number)

Accepts a React Motion spring config.

onSwipeStart: PropTypes.func

Prop callback fired before swipe.

onSwipeMove: PropTypes.func

Prop callback fired during swipe.

onSwipeEnd: PropTypes.func

Prop callback fired after swipe.

onScroll: PropTypes.func

Prop callback fired when track is scrolling. Useful for parallax or progress bars.

onViewChange: PropTypes.func

Prop callback fired when view changes. Passes back the newly selected indicies.

onRest: PropTypes.func

Prop callback fired after track scrolling animation settles.

Public methods

prev

Moves to the previous view.

next

Advances to the next view.

scrollTo

Scroll to a view by it's index or key.

View Props

tag: PropTypes.string

The HTML tag for this element. Defaults to div.

Running Locally

clone repo

git clone [email protected]:souporserious/react-view-pager.git

move into folder

cd ~/react-view-pager

install dependencies

npm install

run dev mode

npm run dev

open your browser and visit: http://localhost:8080/

More Repositories

1

react-measure

📏 Compute measurements of a React component.
JavaScript
1,940
star
2

react-motion-ui-pack

Wrapper component around React Motion for easier UI transitions
JavaScript
625
star
3

react-media-player

React audio and video player.
JavaScript
470
star
4

renoun

Documentation that matches the quality of your product.
TypeScript
416
star
5

restyle

The simplest way to add CSS styles to your React components.
TypeScript
304
star
6

jsxui

The design compiler for JSX.
TypeScript
175
star
7

unicon

🦄 Wrangle SVGs from your favorite design tool.
JavaScript
169
star
8

next-remote-refresh

Enable Fast Refresh for remote data in Next.js
JavaScript
151
star
9

react-aria

Utility components to help compose React ARIA components
JavaScript
144
star
10

react-fluid-container

Graceful dynamic/variable height animation
JavaScript
133
star
11

tsxmod

Refactor code, migrate to new APIs, and better understand your codebase.
TypeScript
111
star
12

reforest

🌲 Collect ordered React render data seamlessly across the server and client.
TypeScript
79
star
13

use-item-list

A primitive React hook used to coordinate indexed collections effortlessly.
JavaScript
74
star
14

lock-scrollbars

Lock all scrollbars to prevent scrolling the page.
TypeScript
73
star
15

sketch-to-svg-json-loader

Sketch to SVG JSON loader module for webpack
JavaScript
63
star
16

documenting-systems-in-nextjs

Case study of how to build a documentation system in Next.js using TS Morph.
TypeScript
52
star
17

mdx-to-md

Convert MDX to Markdown.
TypeScript
51
star
18

next-monaco

TypeScript
45
star
19

react-paper-ripple

Paper ripple animations inspired by Google Material Design
JavaScript
31
star
20

outy

A simple way to listen for events outside of elements in 390 bytes
JavaScript
31
star
21

react-matches

Simple helper components to make responsive design easier in React.
JavaScript
29
star
22

next-dx

Enhance Next.js development with utilities for local and remote content.
TypeScript
21
star
23

react-component-query

Component queries in React
JavaScript
21
star
24

animated-ui

Components for UI animations powered by Animated
JavaScript
21
star
25

build-your-own-code-playground

A simple React code playground built in Next.js
TypeScript
20
star
26

get-node-dimensions

Get accurate element dimensions, even if it's hidden!
JavaScript
20
star
27

selectly

Build composeable select menus for React.
JavaScript
19
star
28

react-midnight

Handle dates, times, and calendars with React.
JavaScript
17
star
29

docgraph

Generate rich documentation data for TypeScript and MDX codebases.
TypeScript
17
star
30

velocitytransitiongroup

React addon component to easily use Velocity animations in React.
JavaScript
17
star
31

use-roving-index

Manage an active index that needs to be contained or wrapped.
TypeScript
16
star
32

golly

Powerful flexbox grid system built on top of glamor.
JavaScript
12
star
33

tonality

Some small functions to help build and adjust color tone palettes.
JavaScript
11
star
34

use-scroll-sync

Sync scroll positions between multiple elements.
TypeScript
10
star
35

use-ref-list

Easily manage an ordered list of refs in React.
JavaScript
8
star
36

react-motion-sortable

Sortable components powered by React Motion.
JavaScript
8
star
37

react-travel

JavaScript
8
star
38

bundling-typescript-with-esbuild-for-npm

Example of bundling TypeScript using Esbuild.
JavaScript
7
star
39

create-styled-element

Simple wrapper around glamor to create styled elements in React.
JavaScript
6
star
40

monaco-textmate-syntax-highlighting

Monaco TextMate Syntax Highlighting in Next.js
TypeScript
6
star
41

nextjs-remote-mdx-fast-refresh

Workaround to get Fast Refresh working for remote MDX content in a local directory.
JavaScript
5
star
42

next-monaco-vscode-api

Monaco Editor x Next.js
TypeScript
5
star
43

react-editable

Build flexible WYSIWYG editors with ease
JavaScript
4
star
44

react-aria-ui

Collection of ARIA compliant React components.
JavaScript
4
star
45

react-rails-theme-provider

Demo of setting up ThemeProvider with react-rails
Ruby
4
star
46

app-router-form

App Router testing.
TypeScript
4
star
47

react-drop

Drop content anywhere on the page
JavaScript
4
star
48

generate-typescript-docs-using-ts-morph

Generate docs from TypeScript using TS Morph.
TypeScript
4
star
49

get-prefix

Get browser style prefixes for Javascript.
JavaScript
4
star
50

animation-bus

Define different animation stops relative to another value.
JavaScript
4
star
51

better-library-dx-using-jsdoc-links

Example of using Babel to enrich JSDoc links with helpful links.
JavaScript
3
star
52

react-cli-example

Example showing how to bundle a CLI tool using react ink and tsup.
JavaScript
3
star
53

scroll-media

Control videos or audio based on scroll position.
JavaScript
3
star
54

preact-signals-nextjs

TypeScript
3
star
55

managing-design-systems-with-typescript

An example of how to manage Design Systems with TypeScript.
TypeScript
3
star
56

site

My personal website 💀
JavaScript
3
star
57

babel-plugin-extract-export

Extract ESM exports and their dependencies using Babel.
TypeScript
3
star
58

contours

An example of generating contours from a 2D array using Rust.
TypeScript
2
star
59

style-bits

JavaScript
2
star
60

reanime

JavaScript
2
star
61

esbuild-figma-plugin

Example showing how to compile Figma plugins using Esbuild.
TypeScript
2
star
62

server-components-css

TypeScript
2
star
63

mdx-bundler-and-styled-components

TypeScript
2
star
64

origins-boilerplate

A starting place for the web. Will add config settings soon.
JavaScript
2
star
65

use-frame

Sync animation frames in React.
TypeScript
2
star
66

docs-example

TypeScript
1
star
67

extract-exports-using-ts-morph

An example of how to extract an ESM export using TS Morph.
TypeScript
1
star
68

args-flags

A simple command line argument parser for Node.
JavaScript
1
star
69

calendar-fns

Small utility functions for building calendars in JavaScript.
TypeScript
1
star
70

data-slider

A simple slider that allows data attributes to control it.
JavaScript
1
star
71

vscode-ast-explorer

TypeScript
1
star
72

next-mdx-table-bug

JavaScript
1
star
73

mdx-use-client

JavaScript
1
star