Skip to content

Instance ​

An instance is returned from Glare.open() and available via Glare.getInstance(). Use it to move between slides, zoom, and drive modules while the lightbox is open.

Properties ​

PropertyTypeMeaning
idnumberUnique id for this instance.
groupSlideItem[]Normalized slides.
optsResolvedOptionsOptions after defaults are merged.
dictI18nDictResolved i18n strings for the active language.
currentSlideItem | nullActive slide.
currIndexnumberActive index.
prevIndexnumberPrevious index.
isActivebooleanWhether the dialog is open.
isClosingbooleanWhether a close animation is in progress.
isIdlebooleanWhether idle chrome is faded.
$refsGlareRefs | nullDOM references while open: container, stage, and optional bg, inner, caption, toolbar, infobar, navigation. null when closed.
zoomZoomZoom controller: scale, x, y, isZoomed, toFit(), toActual({ x, y }).
slideshowSlideshow | undefinedPresent when the slideshow module is enabled.
thumbsThumbs | undefinedPresent when thumbnails are enabled.
fullscreenFullscreen | undefinedPresent when fullscreen is enabled and supported.

Methods ​

MethodWhat it does
open(index?)Open (or jump) to an index.
close()Close this instance.
next()Go to the next slide.
prev()Go to the previous slide.
jumpTo(index)Jump to an absolute index.
toggleZoom(point?)Zoom an image to actual size or back to fit, optionally around a point.
update()Re-sync chrome for the current slide.
focus()Move focus to the dialog container.
toggleControls(force?)Toggle idle chrome, or force idle / visible.
js
const box = Glare.open([{ src: 'a.jpg' }, { src: 'b.jpg' }], { loop: true })
box.jumpTo(1)
box.toggleZoom()
box.close()

Module handles ​

ts
instance.slideshow?.start()
instance.slideshow?.stop()
instance.slideshow?.toggle()
instance.slideshow?.isActive()

instance.thumbs?.show()
instance.thumbs?.hide()
instance.thumbs?.toggle()
instance.thumbs?.focus(index?)

instance.fullscreen?.request()
instance.fullscreen?.exit()
instance.fullscreen?.toggle()
instance.fullscreen?.isFullscreen()

Released under the MIT License.