Socket
Socket
Sign inDemoInstall

react-photoswipe

Package Overview
Dependencies
8
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-photoswipe

PhotoSwipe, PhotoSwipeGallery component for ReactJS base on PhotoSwipe.


Version published
Weekly downloads
4.8K
decreased by-1.02%
Maintainers
2
Install size
0.996 MB
Created
Weekly downloads
 

Readme

Source

React PhotoSwipe

PhotoSwipe, PhotoSwipeGallery component for ReactJS base on PhotoSwipe.

Installation

NPM

npm install --save react-photoswipe

Bower

bower install --save react-photoswipe

Usage

Styles

With webpack:
import 'react-photoswipe/lib/photoswipe.css';
Without webpack:
<link rel="stylesheet" type="text/css" href="path/to/react-photoswipe/lib/photoswipe.css">

JS

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

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';

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/dist/photoswipe.css">
<script src="path/to/react-photoswipe/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

Demo

View demo or example folder.

Keywords

FAQs

Last updated on 12 Jun 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc