Api
Accessing the API
const instance = Chocolat(document.querySelectorAll('.chocolat-image'), {})
const api = instance.api
// or
const { api } = Chocolat(document.querySelectorAll('.chocolat-image'), {})
// or
const api = Chocolat(document.querySelectorAll('.chocolat-image'), {}).apiApi methods
open([index])
// Opens the first image
api.open()
// Opens the 3rd image
api.open(2).then(() => {
console.log('Third image is loaded and animations have finished.')
})close()
prev()
next()
current()
position()
destroy()
getElem(elementName)
get(optionName)
set(optionName, optionValue)
Last updated