Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-photoswipe-2

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-photoswipe-2

react photoswipe component base on Photoswipe. Support React >= 16.

  • 1.3.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5K
Maintainers
1
Weekly downloads
 
Created
Source

React PhotoSwipe

Fork from https://github.com/minhtranite/react-photoswipe

Support React 16, PureComponent

Solved this issue https://github.com/minhtranite/react-photoswipe/issues/9

PhotoSwipe, PhotoSwipeGallery component for ReactJS base on PhotoSwipe.

Demo

View demo or example folder.

Contribute

https://github.com/anhdn/react-photoswipe-2

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

Keywords

FAQs

Package last updated on 30 Apr 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc