JSPM

  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q44543F
  • License MIT

react-sled is a carousel made with react-spring.

Package Exports

  • react-sled

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-sled) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-sled is a Gallery-module made with react-spring. 😽

NPM JavaScript Style Guide

  • Lightweight and performant architecture
  • Touch- and Mousedrag
  • Easy to style with thanks to styled-components
  • Ready for server-side-rendering

🛷 Have a look to the demo-example!

This Project is under development!

Install

Install all dependencies via Yarn or NPM.

yarn add react-sled react-spring react-with-gesture styled-components react react-dom

Usage

import React from "react";
import { Sled, Views, Progress, Control } from "react-sled";

const App = () => {
  return (
    <Sled wrapperHeight="50ow">
      <Views>
        <img src="my-image-1.jpg" alt="My Image" />
        <img src="my-image-2.jpg" alt="My Image" />
      </Views>
      <Progress />
      <div className="controls">
        <Control type="prev" />
        <Control type="next" />
      </div>
    </Sled>
  );
};

export default App;

Props

List of all props:

<Sled
  wrapperWidth
  // Type: Number. Default: undefined
  // Optional. Sets the viewpager’s width.
  wrapperHeight
  // Type: Number or String. Default: "50%"
  // Set the viewpager’s height. A number is pixels.
  // Allowed units: ol ("own width": percent of viewpager’s width), vw, vh, rem, em, px
  auto
  // Type: Number. Default: undefined
  // Activates automatic Sliding.
  // Time in Milliseconds
  config
  // Type: Object. Default: { mass: 1, tension: 210, friction: 20, clamp: true }
  // Animation settings.
  keys
  // Type: Boolean. Default: true
  // Keyboard controls.
  dragDistance
  // Type: String. Default: 25ow
  // Distance, the user has to drag the slider to trigger action.
/>
<Progress
  style
  // Type: String.
  // Default: `
  //   height: 4px;
  //   background: black;
  //   margin: 10px 0;

  //   .viewpager-progress-bar {
  //     background: red;
  //   }
  //   .viewpager-progress-separator {
  //     width: 4px;
  //     background: white;
  //   }
  // `
/>
<Control
  type
  // Type: String.
  // Default: 'next'
  // Possible values: 'prev', 'next'

  style
  // Type: String.
  // Default: `
  //  cursor: pointer;
  //  padding: 10px;
  //  width: 40px;
  //  height: 40px;
  //`
  // If you provide a style, the default gets deleted.

To-Do

  • Control animation on drag
  • Better accessibility
  • Infinity-Mode
  • Nice documentation with live examples (using Docz)
  • Stricter type-checking / props validation
  • automated testing

Contributing

Every contribution is very much appreciated.

If you like react-sled, don't hesitate to star it on GitHub.

License

MIT © AndreasFaust

Thanks

This library is an derived the great work and especially from this code-sandbox-example provided by Paul Henschel and the react-spring-team.

Thanks also to the creators of create-react-hook and create-react-library.