svelte-photoswipe-gallery
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Svelete PhotoSwipe Gallery

The easiest way to us a Photoswipe Lightbox with a Masonry Gallery in Svelte.

How to use it

<script>
	import PhotoswipeGallery from 'svelte-photoswipe-gallery';

	const images = [
		{
			src: 'https://source.unsplash.com/random',
			preview: 'https://source.unsplash.com/random',
			width: 400,
			height: 600,
			description: 'Lorem ipsum dolor sit amet',
			alt: 'Random'
		},
		{
			src: 'https://source.unsplash.com/random',
			width: 800,
			height: 1200,
			description: 'Lorem ipsum dolor sit amet',
			alt: 'Random'
		},
		{
			src: 'https://source.unsplash.com/random',
			width: 300,
			height: 200,
			description: 'Lorem ipsum dolor sit amet',
			alt: 'Random'
		},
		{
			src: 'https://source.unsplash.com/random',
			width: 600,
			height: 400,
			description: 'Lorem ipsum dolor sit amet',
			alt: 'Random'
		}
	];
</script>

<PhotoswipeGallery
	{images}
	showDescription="{false}"
	showDownloadButton="{false}"
	showFullscreenButton="{false}"
/>

Options

Name Type Default Description
images Array [] Array of image objects with at least src, width and height
showDescription Boolean true Shows the description of the image at the bottom of the opened Lightbox
showDownloadButton Boolean true Shows the download button in the opened Lightbox
showFullscreenButton Boolean true Shows the fullscreen button in the opened Lightbox

Image Object

Name Type Required Description
src String yes The source of the image.
preview String no The source of the preview image, if given, that's the image shown in the Masonry Gallery.
width Number yes The width of the image in the opened Lightbox.
height Number yes The height of the image in the opened Lightbox.
description String no The description of the image, used for the description in the opened Lightbox (if showDescription = true).
alt String no (but recommended) The alt text of the image, used for the description text of the image in the opened Lightbox, if no description is available. Also used if the Picture can't get loaded or for Screenreaders.

Demo

See also the Demo on CodeSandbox.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.41latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.41
0.0.30
0.0.20
0.0.10

Package Sidebar

Install

npm i svelte-photoswipe-gallery

Weekly Downloads

1

Version

0.0.4

License

none

Unpacked Size

799 kB

Total Files

16

Last publish

Collaborators

  • fanki