Gathering detailed insights and metrics for react-spring-lightbox
Gathering detailed insights and metrics for react-spring-lightbox
Gathering detailed insights and metrics for react-spring-lightbox
Gathering detailed insights and metrics for react-spring-lightbox
npm install react-spring-lightbox
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
243 Stars
174 Commits
27 Forks
6 Watching
18 Branches
4 Contributors
Updated on 23 Oct 2024
Minified
Minified + Gzipped
TypeScript (70.93%)
JavaScript (29.07%)
Cumulative downloads
Total Downloads
Last day
-23.7%
826
Compared to previous day
Last week
-14.3%
4,662
Compared to previous week
Last month
0.8%
20,968
Compared to previous month
Last year
-16.7%
293,736
Compared to previous year
3
3
46
React-spring-lightbox is a flexible image gallery lightbox with native-feeling touch gestures and buttery smooth animations.
Mousewheel
, swipe or click+drag to page photosMousewheel
or Trackpad Pinch
to zoom<img />
attribute including loading
(lazy loading), srcset
and aria-*
1yarn add react-spring-lightbox
The images
prop now accepts a list of objects whose properties can be almost any valid React <img />
prop including srcset
, loading
(lazy loading) and aria-*
attributes.
If you use typescript, the exact type can be imported from import { ImagesListType } from 'react-spring-lightbox';
1import React, { useState } from 'react'; 2import Lightbox, { ImagesListType } from 'react-spring-lightbox'; 3 4const images: ImagesListType = [ 5 { 6 src: 'https://timellenberger.com/static/blog-content/dark-mode/win10-dark-mode.jpg', 7 loading: 'lazy', 8 alt: 'Windows 10 Dark Mode Setting', 9 }, 10 { 11 src: 'https://timellenberger.com/static/blog-content/dark-mode/macos-dark-mode.png', 12 loading: 'lazy', 13 alt: 'macOS Mojave Dark Mode Setting', 14 }, 15 { 16 src: 'https://timellenberger.com/static/blog-content/dark-mode/android-9-dark-mode.jpg', 17 loading: 'lazy', 18 alt: 'Android 9.0 Dark Mode Setting', 19 }, 20]; 21 22const CoolLightbox = () => { 23 const [currentImageIndex, setCurrentIndex] = useState(0); 24 25 const gotoPrevious = () => 26 currentImageIndex > 0 && setCurrentIndex(currentImageIndex - 1); 27 28 const gotoNext = () => 29 currentImageIndex + 1 < images.length && 30 setCurrentIndex(currentImageIndex + 1); 31 32 return ( 33 <Lightbox 34 isOpen={true} 35 onPrev={gotoPrevious} 36 onNext={gotoNext} 37 images={images} 38 currentIndex={currentImageIndex} 39 /* Add your own UI */ 40 // renderHeader={() => (<CustomHeader />)} 41 // renderFooter={() => (<CustomFooter />)} 42 // renderPrevButton={() => (<CustomLeftArrowButton />)} 43 // renderNextButton={() => (<CustomRightArrowButton />)} 44 // renderImageOverlay={() => (<ImageOverlayComponent >)} 45 46 /* Add styling */ 47 // className="cool-class" 48 // style={{ background: "grey" }} 49 50 /* Handle closing */ 51 // onClose={handleClose} 52 53 /* Use single or double click to zoom */ 54 // singleClickToZoom 55 56 /* react-spring config for open/close animation */ 57 // pageTransitionConfig={{ 58 // from: { transform: "scale(0.75)", opacity: 0 }, 59 // enter: { transform: "scale(1)", opacity: 1 }, 60 // leave: { transform: "scale(0.75)", opacity: 0 }, 61 // config: { mass: 1, tension: 320, friction: 32 } 62 // }} 63 /> 64 ); 65}; 66 67export default CoolLightbox;
Prop | Description |
---|---|
isOpen | Flag that dictates if the lightbox is open or closed |
onClose | Function that closes the Lightbox |
onPrev | Function that changes currentIndex to previous image in images |
onNext | Function that changes currentIndex to next image in images |
currentIndex | Index of image in images array that is currently shown |
renderHeader | A React component that renders above the image pager |
renderFooter | A React component that renders below the image pager |
renderPrevButton | A React component that is used for previous button in image pager |
renderNextButton | A React component that is used for next button in image pager |
renderImageOverlay | A React component that renders within the image stage, useful for creating UI overlays on top of the current image |
singleClickToZoom | Overrides the default behavior of double clicking causing an image zoom to a single click |
images | Array of image objects to be shown in Lightbox |
className | Classes are applied to the root lightbox component |
style | Inline styles are applied to the root lightbox component |
pageTransitionConfig | React-Spring useTransition config for page open/close animation |
Clone the repo
1git clone https://github.com/tim-soft/react-spring-lightbox.git react-spring-lightbox 2cd react-spring-lightbox
Setup symlinks
1yarn link 2cd example 3yarn link react-spring-lightbox
Run the library in development mode
1yarn start
Run the example app in development mode
1cd example 2yarn dev
Changes to the library code should hot reload in the demo app
MIT © Tim Ellenberger
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/30 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
13 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More