1.4.0 • Published 9 years ago

react-picture-show v1.4.0

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

React Picture Show Build Status NPM version

A Bare bones slideshow component that handles transitions between slides and exposes control so that it is easy to decorate with other controls. Out of the box, it supports swiping to paginate, clicking left and right, and lasyloading slides

PictureShow Demo

installation

node

npm install react-picture-show

Usage

Basic

  
<PictureShow>
  <img src='http://...'/>
  <img src='http://...'/>
  <div>another thing</div>
  <img src='http://...'/>
  <img src='http://...'/>
</PictureShow>

Component Properties Overview

PropertiesTypeDefaultDescriptionSupported
ratioArrayNullShape of the slideshow, for example: [16,9]yes
animationSpeedNumber1500Speed of slide transitions in px/syes
startingSlideNumber0Initial slide viewyes
onClickSlideFunctionnulloverride click handler for slideyes
onBeforeTransitionFunctionnoopFunction called before transition startsyes
onAfterTransitionFunctionnoopFunction called after transition endsno
slideBufferNumber1The number of slides loaded to the left and right of the slide in viewyes
clickDivideNumber0.45The division between previous and next when clicking the slideshowyes
infiniteBooleantrueIs the Slideshow continuousno
suppressPendingBooleantrueShould slides outside the slideBuffer be suppressedno

Public methods on mounted component

MethodDescriptionSupported
nextGo forward one slideyes
previousGo backward one slideyes
goToSlideGo to a specific slide indexyes
disableDeactivate slideshowno
enableActicate slideshowno

How slides work

Slides are the direct child components of a <PictureShow/>. They are cloned with the following additional properties:

{
  slideRatio: Number, // the ratio of the outer slide (w/h)
  slidePending: Boolean // whether the slide can be lazyloaded
}

By cloning the children with these props, you are free to create 'slide' components that react to them however you want. If the child already has one of these props it will be replaced (even for <img/> components)

Note: If suppressPending property is true on <PictureShow/>, then the slide will not render, so you will not need to handle the pending prop at the slide level. suppressPending exists for edge cases where the user wants to define how 'not loading' works

Properties in Depth

ratio

Defines the shape of the slideshow as a fixed ratio so that it can flex inside its parent container.

animationSpeed

speed...

startingSlide

staring slide...

onClickSlide

function...

onBeforeTransition

function...

onAfterTransition

function...

slideBuffer

lazy loading...

clickDivide

next and prev...

infinite

more stuff...

suppressPending

control pending....

License

MIT

1.4.0

9 years ago

1.3.1

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago