1.3.3 • Published 6 years ago

react-photoswipe-temp v1.3.3

Weekly downloads
18
License
-
Repository
-
Last release
6 years ago

React PhotoSwipe

PhotoSwipe, PhotoSwipeGallery component for ReactJS base on PhotoSwipe. With small fixes to prevent crashes of the original PhotoSwipe.

Installation

NPM

npm install --save react-photoswipe-temp

Usage

Styles

With webpack:

import 'react-photoswipe-temp/lib/photoswipe.css';

Without webpack:

<link rel="stylesheet" type="text/css" href="path/to/react-photoswipe-temp/lib/photoswipe.css">

JS

PhotoSwipe

import {PhotoSwipe} from 'react-photoswipe-temp';

let isOpen = true;

let items = [
  {
    src: 'http://lorempixel.com/1200/900/sports/1',
    w: 1200,
    h: 900,
    title: 'Image 1'
  },
  {
    src: 'http://lorempixel.com/1200/900/sports/2',
    w: 1200,
    h: 900,
    title: 'Image 2'
  }
];

let options = {
  //http://photoswipe.com/documentation/options.html
};

handleClose = () => {
  isOpen: false
};

<PhotoSwipe isOpen={isOpen} items={items} options={options} onClose={handleClose}/>

PhotoSwipeGallery

import {PhotoSwipeGallery} from 'react-photoswipe-temp';

let items = [
  {
    src: 'http://lorempixel.com/1200/900/sports/1',
    thumbnail: 'http://lorempixel.com/120/90/sports/1',
    w: 1200,
    h: 900,
    title: 'Image 1'
  },
  {
    src: 'http://lorempixel.com/1200/900/sports/2',
    thumbnail: 'http://lorempixel.com/120/90/sports/2',
    w: 1200,
    h: 900,
    title: 'Image 2'
  }
];

let options = {
  //http://photoswipe.com/documentation/options.html
};

getThumbnailContent = (item) => {
  return (
    <img src={item.thumbnail} width={120} height={90}/>
  );
}

<PhotoSwipeGallery items={items} options={options} thumbnailContent={getThumbnailContent}/>

UMD

<link rel="stylesheet" type="text/css" href="path/to/react-photoswipe-temp/dist/photoswipe.css">
<script src="path/to/react-photoswipe-temp/dist/react-photoswipe.js"></script>
var PhotoSwipe = window.ReactPhotoswipe.PhotoSwipe;
var PhotoSwipeGallery = window.ReactPhotoswipe.PhotoSwipeGallery;

Example here

Props

Note: The first argument of every listener is a Photoswipe instance.

EX:

beforeChange(instance, change);
imageLoadComplete(instance, index, item);

PhotoSwipe

NameTypeDefaultRequiredDescription
isOpenboolfalsetrue
itemsarray[]truehttp://photoswipe.com/documentation/getting-started.html
optionsobject{}falsehttp://photoswipe.com/documentation/options.html
onClosefunctionfalseCallback after PhotoSwipe close
idstringfalse
classNamestringpswp
beforeChangefunctionfalsePhotoswipe event listener
afterChangefunctionfalsePhotoswipe event listener
imageLoadCompletefunctionfalsePhotoswipe event listener
resizefunctionfalsePhotoswipe event listener
gettingDatafunctionfalsePhotoswipe event listener
mouseUsedfunctionfalsePhotoswipe event listener
initialZoomInfunctionfalsePhotoswipe event listener
initialZoomInEndfunctionfalsePhotoswipe event listener
initialZoomOutfunctionfalsePhotoswipe event listener
initialZoomOutEndfunctionfalsePhotoswipe event listener
parseVerticalMarginfunctionfalsePhotoswipe event listener
closefunctionfalsePhotoswipe event listener
unbindEventsfunctionfalsePhotoswipe event listener
destroyfunctionfalsePhotoswipe event listener
updateScrollOffsetfunctionfalsePhotoswipe event listener
preventDragEventfunctionfalsePhotoswipe event listener
shareLinkClickfunctionfalsePhotoswipe event listener

PhotoSwipeGallery

NameTypeDefaultRequiredDescription
itemsarray[]truehttp://photoswipe.com/documentation/getting-started.html
optionsobject{}falsehttp://photoswipe.com/documentation/options.html
thumbnailContentfunction<img src={item.src} width='100' height='100'/>falseThumbnail content
isOpenboolfalsefalseUse it with onClose prop
onClosefunctionfalseCallback after close
idstringfalse
classNamestringpswp-gallery
beforeChangefunctionfalsePhotoswipe event listener
afterChangefunctionfalsePhotoswipe event listener
imageLoadCompletefunctionfalsePhotoswipe event listener
resizefunctionfalsePhotoswipe event listener
gettingDatafunctionfalsePhotoswipe event listener
mouseUsedfunctionfalsePhotoswipe event listener
initialZoomInfunctionfalsePhotoswipe event listener
initialZoomInEndfunctionfalsePhotoswipe event listener
initialZoomOutfunctionfalsePhotoswipe event listener
initialZoomOutEndfunctionfalsePhotoswipe event listener
parseVerticalMarginfunctionfalsePhotoswipe event listener
closefunctionfalsePhotoswipe event listener
unbindEventsfunctionfalsePhotoswipe event listener
destroyfunctionfalsePhotoswipe event listener
updateScrollOffsetfunctionfalsePhotoswipe event listener
preventDragEventfunctionfalsePhotoswipe event listener
shareLinkClickfunctionfalsePhotoswipe event listener