Sets whether lightbox will open and fill the whole page (default), or whether it should open in a particular block of the page.
For example if we want to display the lightbox in the block #my-container:
imageSize
default : 'scale-down'type : String
possible values : 'scale-down', 'contain', 'native', or 'cover'
For a more detailed explanations see the Images sizes page :
'scale-down' : if the image is bigger than the window it's resized to fit.
If the image is smaller than the window it's not streched, just displayed at native dimensions.
'contain' : if the image is bigger than the window it's resized to fit.
If the image is smaller than the window it's streched, to fit the window.
'cover' : the image cover the window, no white spaces are displayed.
'native' : the image is never streched nor shrinked, always displayed at native dimensions.
linkImages
default : truetype : Boolean
Sets whether we can switch from one image to another, without closing the viewer (true),
or if the images can only be openned one by one (false).
className
default : undefinedtype : String
Adds a custom css classes to the parent of the lightbox.
loop
default : falsetype : Boolean
When true:
last image + 1 leads to first image.
first image - 1 leads to last image.
closeOnBackgroundClick
default : truetype : Boolean
Closes Chocolat when the background is clicked.
firstImageIndex
default : 0type : Number
Index of the image that you want to start the series.
lastImageIndex
default : images.length - 1type : Number
Index of the image that you want to start the series.
setTitle
default : undefinedtype : Function
Function returning the title of the image set.
You can access the Chocolat instance inside the function unsing this.
description
default : title html attribute of the image
type : Function
Function returning the description of the image.
You can acces s the Chocolat instance inside the function unsing this.
pagination
default : function returning position + '/' + lasttype : Function
Function returning the pagination informations.
You can acces s the Chocolat instance inside the function unsing this.
imageSourceAttribute
default : 'href'type : String
Custom attribute to read the image source from.
fullScreen
default : falsetype : Boolean
Opens Chocolat fullscreen (hides the browser window).
allowZoom
default : truetype : Boolean
Disable or enable the zooming feature.
afterInitialize
default : empty functiontype : Function
Function (hook) called just after chocolat gets initialized.
afterMarkup
default : empty functiontype : Function
Function (hook) called just after markup is created.
You can use it to alter the default markup: to move the caption at the top of the image for example.
afterImageLoad
default : empty functiontype : Function
Function (hook) called just after an image is loaded.
afterClose
default : empty functiontype : Function
Function (hook) called just after Chocolat is closed.
zoomedPaddingX
default : function returning 0type : Function
Function returning the horizontal padding to add around the image when it's zoomed.
It takes 2 arguments canvasWidth and imgWidth
zoomedPaddingY
default : function returning 0type : Function
Function returning the vertical padding to add around the image when it's zoomed.
It takes 2 arguments canvasHeight and imgHeight
{
pagination: function () {
const last = this.settings.lastImageIndex + 1
const position = this.settings.currentImageIndex + 1
return position + '/' + last
}
}
{
imageSourceAttribute: 'data-image-source'
}
{
fullScreen: true
}
{
allowZoom: false
}
{
afterInitialize: function () {
// your logic here
}
}
{
afterMarkup: function () {
this.elems.description.appendTo(this.elems.top)
}
}
{
afterImageLoad: function () {
// your logic here
}
}
{
afterClose: function () {
// your logic here
}
}