Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
react-image-gallery
Advanced tools
react-image-gallery is a flexible and customizable image gallery component for React applications. It allows developers to create responsive and interactive image galleries with features like slide shows, thumbnails, and full-screen mode.
Basic Image Gallery
This code sample demonstrates how to create a basic image gallery using react-image-gallery. The gallery displays a series of images with corresponding thumbnails.
import React from 'react';
import ImageGallery from 'react-image-gallery';
const images = [
{
original: 'https://example.com/image1.jpg',
thumbnail: 'https://example.com/thumb1.jpg',
},
{
original: 'https://example.com/image2.jpg',
thumbnail: 'https://example.com/thumb2.jpg',
},
{
original: 'https://example.com/image3.jpg',
thumbnail: 'https://example.com/thumb3.jpg',
},
];
const MyGallery = () => (
<ImageGallery items={images} />
);
export default MyGallery;
Auto Play Slide Show
This code sample shows how to enable the auto-play feature in the image gallery. The gallery will automatically cycle through the images.
import React from 'react';
import ImageGallery from 'react-image-gallery';
const images = [
{
original: 'https://example.com/image1.jpg',
thumbnail: 'https://example.com/thumb1.jpg',
},
{
original: 'https://example.com/image2.jpg',
thumbnail: 'https://example.com/thumb2.jpg',
},
{
original: 'https://example.com/image3.jpg',
thumbnail: 'https://example.com/thumb3.jpg',
},
];
const MyGallery = () => (
<ImageGallery items={images} autoPlay={true} />
);
export default MyGallery;
Full-Screen Mode
This code sample demonstrates how to enable the full-screen mode in the image gallery. Users can view images in full-screen by clicking the full-screen button.
import React from 'react';
import ImageGallery from 'react-image-gallery';
const images = [
{
original: 'https://example.com/image1.jpg',
thumbnail: 'https://example.com/thumb1.jpg',
},
{
original: 'https://example.com/image2.jpg',
thumbnail: 'https://example.com/thumb2.jpg',
},
{
original: 'https://example.com/image3.jpg',
thumbnail: 'https://example.com/thumb3.jpg',
},
];
const MyGallery = () => (
<ImageGallery items={images} showFullscreenButton={true} />
);
export default MyGallery;
react-photo-gallery is a React component for creating responsive image galleries. It offers a more grid-based layout compared to react-image-gallery and is optimized for performance with features like lazy loading.
react-images is a lightbox component for displaying images in a modal. It focuses on providing a simple and customizable lightbox experience, whereas react-image-gallery offers a more comprehensive gallery solution.
react-slick is a carousel component for React. It is highly customizable and supports various types of content, not just images. It is more versatile in terms of content types compared to react-image-gallery.
Responsive image gallery, slideshow, carousel
npm install react-image-gallery
Live demo: linxtion.com/demo/react-image-gallery
To build the example locally, run:
npm install
gulp dev
You might need to run the following command if you do not have gulp installed globally.
npm install --global gulp
Then open localhost:8001
in a browser.
@import "../node_modules/react-image-gallery/src/ImageGallery";
<link rel="stylesheet" href="/image-gallery.css"/>
var ImageGallery = require('react-image-gallery');
var images = [
{
original: 'http://lorempixel.com/1000/600/nature/1/',
thumbnail: 'http://lorempixel.com/250/150/nature/1/'
},
{
original: 'http://lorempixel.com/1000/600/nature/2/',
thumbnail: 'http://lorempixel.com/250/150/nature/2/'
},
{
original: 'http://lorempixel.com/1000/600/nature/3/',
thumbnail: 'http://lorempixel.com/250/150/nature/3/'
}
];
handleSlide: function(index) {
console.log('Slid to ' + index);
},
render: function() {
return (
<ImageGallery
items={images}
autoPlay={true}
slideInterval={4000}
onSlide={this.handleSlide}/>
);
}
items
: (required) Array of images,showThumbnails
: Boolean, default true
showBullets
: Boolean, default false
autoPlay
: Boolean, default false
slideInterval
: Integer, default 4000
onSlide
: Function, callback(index)
play()
: continuous plays if image is not hovered.pause()
: pauses the slides.slideToIndex(index)
: slide to a specific index.MIT
FAQs
React carousel image gallery component with thumbnail and mobile support
The npm package react-image-gallery receives a total of 110,835 weekly downloads. As such, react-image-gallery popularity was classified as popular.
We found that react-image-gallery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.