
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
org.webjars.npm:react-image-gallery
Advanced tools
Live demo: linxtion.com/demo/react-image-gallery
React image gallery is a React component for building image galleries and carousels
Features of react-image-gallery
npm install react-image-gallery
# SCSS
@import "node_modules/react-image-gallery/styles/scss/image-gallery.scss";
# CSS
@import "node_modules/react-image-gallery/styles/css/image-gallery.css";
# Webpack
import "react-image-gallery/styles/css/image-gallery.css";
# Stylesheet with no icons
node_modules/react-image-gallery/styles/scss/image-gallery-no-icon.scss
node_modules/react-image-gallery/styles/css/image-gallery-no-icon.css
Need more example? See example/app.js
import ImageGallery from 'react-image-gallery';
class MyComponent extends React.Component {
render() {
const 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/'
}
]
return (
<ImageGallery items={images} />
);
}
}
items
: (required) Array of objects, see example above,
original
- image src urlthumbnail
- image thumbnail src urloriginalClass
- custom image classthumbnailClass
- custom thumbnail classrenderItem
- Function for custom renderer (see renderItem below)renderThumbInner
- Function for custom thumbnail renderer (see renderThumbInner below)originalAlt
- image altthumbnailAlt
- thumbnail image altoriginalTitle
- image titlethumbnailTitle
- thumbnail image titlethumbnailLabel
- label for thumbnaildescription
- description for imagesrcSet
- image srcset (html5 attribute)sizes
- image sizes (html5 attribute)infinite
: Boolean, default true
lazyLoad
: Boolean, default false
showNav
: Boolean, default true
showThumbnails
: Boolean, default true
thumbnailPosition
: String, default bottom
top, right, bottom, left
showFullscreenButton
: Boolean, default true
useBrowserFullscreen
: Boolean, default true
showPlayButton
: Boolean, default true
showBullets
: Boolean, default false
showIndex
: Boolean, default false
autoPlay
: Boolean, default false
disableThumbnailScroll
: Boolean, default false
slideOnThumbnailHover
: Boolean, default false
disableArrowKeys
: Boolean, default false
disableSwipe
: Boolean, default false
defaultImage
: String, default undefined
indexSeparator
: String, default ' / '
, ignored if showIndex
is false
slideDuration
: Number, default 450
swipingTransitionDuration
: Number, default 0
slideInterval
: Number, default 3000
flickThreshold
: Number (float), default 0.4
swipeThreshold
: Number, default 30
stopPropagation
: Boolean, default false
preventDefaultTouchmoveEvent
: Boolean, default false
startIndex
: Number, default 0
onImageError
: Function, callback(event)
onThumbnailError
: Function, callback(event)
onThumbnailClick
: Function, callback(event, index)
onImageLoad
: Function, callback(event)
onSlide
: Function, callback(currentIndex)
onScreenChange
: Function, callback(fullscreenElement)
onPause
: Function, callback(currentIndex)
onPlay
: Function, callback(currentIndex)
onClick
: Function, callback(event)
onTouchMove
: Function, callback(event) on gallery slide
onTouchEnd
: Function, callback(event) on gallery slide
onTouchStart
: Function, callback(event) on gallery slide
onMouseOver
: Function, callback(event) on gallery slide
onMouseLeave
: Function, callback(event) on gallery slide
renderCustomControls
: Function, custom controls rendering
_renderCustomControls() {
return <a href='' className='image-gallery-custom-action' onClick={this._customAction.bind(this)}/>
}
renderItem
: Function, custom item rendering
[{thumbnail: '...', renderItem: this.myRenderItem}]
orImageGallery
to completely override _renderItem
, see source for referencerenderThumbInner
: Function, custom thumbnail rendering
[{thumbnail: '...', renderThumbInner: this.myRenderThumbInner}]
orImageGallery
to completely override _renderThumbInner
, see source for referencerenderLeftNav
: Function, custom left nav component
onClick
callback that will slide to the previous item and disabled
argument for when to disable the nav renderLeftNav(onClick, disabled) {
return (
<button
className='image-gallery-custom-left-nav'
disabled={disabled}
onClick={onClick}/>
)
}
renderRightNav
: Function, custom right nav component
onClick
callback that will slide to the next item and disabled
argument for when to disable the nav renderRightNav(onClick, disabled) {
return (
<button
className='image-gallery-custom-right-nav'
disabled={disabled}
onClick={onClick}/>
)
}
renderPlayPauseButton
: Function, play pause button component
onClick
callback that will toggle play/pause and isPlaying
argument for when gallery is playing renderPlayPauseButton: (onClick, isPlaying) => {
return (
<button
type='button'
className={
`image-gallery-play-button${isPlaying ? ' active' : ''}`}
onClick={onClick}
/>
);
}
renderFullscreenButton
: Function, custom fullscreen button component
onClick
callback that will toggle fullscreen and isFullscreen
argument for when fullscreen is active renderFullscreenButton: (onClick, isFullscreen) => {
return (
<button
type='button'
className={
`image-gallery-fullscreen-button${isFullscreen ? ' active' : ''}`}
onClick={onClick}
/>
);
},
play()
: plays the slidespause()
: pauses the slidesfullScreen()
: activates full screenexitFullScreen()
: deactivates full screenslideToIndex(index)
: slides to a specific indexgetCurrentIndex()
: returns the current indexgit clone https://github.com/xiaolin/react-image-gallery.git
cd react-image-gallery
npm install
npm start
Then open localhost:8001
in a browser.
MIT
FAQs
WebJar for react-image-gallery
We found that org.webjars.npm:react-image-gallery demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.