mosaicgallery / GalleryConfig
Interface: GalleryConfig
Defined in: gallery/config.ts:8
Main configuration object for a MosaicGallery. Configuration can be declared partially and any remaining options will be filled with default options.
Extends
Partial<Omit<GalleryConfigImpl,"layout">>
Properties
debounceDuration?
optionaldebounceDuration?:number
Defined in: gallery/config.ts:49
The number of milliseconds to wait before redrawing the layout when the size changes.
Default
0Inherited from
GalleryConfigImpl.debounceDuration
elementSelector?
optionalelementSelector?:string
Defined in: gallery/config.ts:44
The selector to select all elements which should be added to the gallery.
Default
".mosaic-gallery-element"Inherited from
GalleryConfigImpl.elementSelector
hoverEffect?
optionalhoverEffect?:string
Defined in: gallery/config.ts:73
The effect applied to an image when hovered above it with the mouse.
Default
HoverEffect.NoneInherited from
layout?
optionallayout?:PartialLayoutConfig
Defined in: gallery/config.ts:10
Which layout to use for the gallery. See the docs for all available options.
lazyLoading?
optionallazyLoading?:Boolean
Defined in: gallery/config.ts:67
Whether lazy loading is enabled. Disabling this can save resources when lazy loading is not used. Every image element in the gallery with a 'mscglry-data-src' attribute will have this attribute moved to the regular src attribute as soon as the image is scrolled into view.
Default
falseExample
An example element for lazy loading:
<a class="mosaic-gallery-element" href="/high-resolution-image.jpg"
><img src="/small-thumbnail.jpg" mscglry-data-src="/high-resolution-image.jpg"
/></a>Inherited from
onImageReady?
optionalonImageReady?: (data) =>void
Defined in: gallery/config.ts:103
Callback called whenever an image was loaded and its dimensions are known. This can e.g. be used to add the image size to each element for a lightbox. Do note that this function is also called for the first version of the image that is loaded. I.e. when lazy loading is enabled, this function is called with the dimensions of the initial low resolution image. However, it will also be called again as soon as the full resolution lazy loaded image is loaded.
To be precise, the first time this function is called, it is called with the dimensions obtained from the following priority:
- dimensions of the initial image, when the image is already loaded when the gallery is constructed
- dimensions in the html width/height attribute of the image when present
- dimension of the initial image, when the image wans't loaded when the gallery is constructed Then, it is called again with the dimensions of the lazy loaded image.
Parameters
data
the gallery element with its size populated
Returns
void
Default
undefinedExample
onImageReady: (image) => {
if (!image.width || !image.height)
throw new Error("Image size not known!");
image.element.setAttribute("lightbox-width", image.width.toString());
image.element.setAttribute("lightbox-height", image.height.toString());
},