This is an image gallery for Svelte based on react-image-gallery v1.2.11. Many thanks to all the contributors of that package for their hard work!
react2svelte.github.io/image-gallery/.
React image gallery is a React component for building image galleries and carousels
play
, pause
, slide
, beforeslide
, screenchange
, imageload
, imageerror
, click
eventsNot yet ported
Install the library
npm i @react2svelte/image-gallery
Use it in your component/page
<script lang="ts">
import ImageGallery from '@react2svelte/image-gallery';
const images = [
{
original: 'https://picsum.photos/id/1018/1000/600/',
thumbnail: 'https://picsum.photos/id/1018/250/150/'
},
{
original: 'https://picsum.photos/id/1015/1000/600/',
thumbnail: 'https://picsum.photos/id/1015/250/150/'
},
{
original: 'https://picsum.photos/id/1019/1000/600/',
thumbnail: 'https://picsum.photos/id/1019/250/150/'
}
];
</script>
<ImageGallery items="{images}" />
You can also have a look at the demo page of the package, it allows setting library settings interactively. To run it locally:
git clone https://github.com/react2svelte/image-gallery.git
cd image-gallery
npm install
npm run dev
And open http://localhost:5173/
items
: (required) Array of objects, see example above,original
- image src urlthumbnail
- image thumbnail src urlfullscreen
- image for fullscreen (defaults to original)originalHeight
- image height (html5 attribute)originalWidth
- image width (html5 attribute)loading
- image loading. Either "lazy" or "eager" (html5 attribute)thumbnailHeight
- image height (html5 attribute)thumbnailWidth
- image width (html5 attribute)thumbnailLoading
- image loading. Either "lazy" or "eager" (html5 attribute)originalClass
- custom image classthumbnailClass
- custom thumbnail classrenderItem
- Function for custom rendering a specific slide (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)bulletClass
- extra class for the bullet of the iteminfinite
: 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
useTranslate3D
: Boolean, default true
translate
instead of translate3d
css property to transition slidesshowPlayButton
: Boolean, default true
isRTL
: Boolean, default false
showBullets
: Boolean, default false
showIndex
: Boolean, default false
autoPlay
: Boolean, default false
disableThumbnailScroll
: Boolean, default false
disableKeyDown
: Boolean, default false
disableSwipe
: Boolean, default false
disableThumbnailSwipe
: Boolean, default false
onErrorImageURL
: String, default undefined
indexSeparator
: String, default ' / '
, ignored if showIndex
is falseslideDuration
: Number, default 450
swipingTransitionDuration
: Number, default 0
slideInterval
: Number, default 3000
slideOnThumbnailOver
: Boolean, default false
flickThreshold
: Number (float), default 0.4
swipeThreshold
: Number, default 30
stopPropagation
: Boolean, default false
startIndex
: Number, default 0
additionalClass
: String,useWindowKeyDown
: Boolean, default true
true
, listens to keydown events on window (window.addEventListener)false
, listens to keydown events on image gallery element (imageGalleryElement.addEventListener)The following functions can be accessed:
play()
: plays the slidespause()
: pauses the slidesfullScreen()
: activates full screenexitFullScreen()
: deactivates full screenslideToIndex(index)
: slides to a specific indexgetCurrentIndex()
: returns the current indexAlready supported
slide
: Function, details: { currentIndex: number }
beforeslide
: Function, details: { nextIndex: number }
screenchange
: Function, details: { fullscreen: boolean }
pause
: Function, details: { currentIndex: number }
play
: Function, details: { currentIndex: number }
imageload
: Function, details: { index: number, event }
imageerror
: Function, details: { index: number, event }
click
: Function, details: event
Not yet supported
onThumbnailError
: Function, callback(event)
onThumbnailClick
: Function, callback(event, index)
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
react-image-gallery
supports rendering custom controls, this feature has not been ported yet.
MIT