Methods

Available API methods


There are methods, setters and getters on a GLightbox object. The easiest way to access the GLightbox object is to set the return value from your call to a variable. For example:

const lightbox = GLightbox({ ...options });

Available Methods

open

Open the lightbox, you can optionally pass a node.

MethodParametersReturns
opennumber or HTMLElement or undefinedvoid

close

Close the lightbox.

MethodParametersReturns
close-void

reload

The reload method will set again event listeners, use this methid if you are inserting content dinamically in your page.

MethodParametersReturns
reload-void

destroy

Destroy and remove all attached events.

MethodParametersReturns
destroy-void

prevSlide

Go to the previous slide.

MethodParametersReturns
prevSlide-void

nextSlide

Go to the next slide.

MethodParametersReturns
nextSlide-void

goToSlide

Go to a specific slide, to call this method the lightbox must be already open.

MethodParametersReturns
goToSlidenumbervoid

insertSlide

Insert a slide at the specified position.

MethodParametersReturns
insertSlideobject, numbervoid

removeSlide

Remove slide at the specified index

MethodParametersReturns
removeSlidenumbervoid

getActiveSlide

Get active slide. It will return the active node.

MethodParametersReturns
getActiveSlide-HTMLElement

getActiveSlideIndex

Get active slide. It will return the active slide index.

MethodParametersReturns
getActiveSlideIndex-number

setElements

Update the lightbox gallery elements.

MethodParametersReturns
setElementsarrayvoid