Skip to content

Configuration Overview

Zoomora is initialised with an optional configuration object. All options have sensible defaults so you can call new Zoomora() with no arguments and get a fully working lightbox. Pass only the options you want to change.

new Zoomora({
  transition: 'slide',
  showThumbnails: false
});

Full Options Reference

OptionTypeDefaultDescription
selectorString'[data-zoomora]'CSS selector for lightbox trigger elements
showCounterBooleantrueShow the image counter (e.g. 2 / 5)
showThumbnailsBooleantrueShow the thumbnail strip at the bottom
showZoomBooleantrueShow the zoom button
showFullscreenBooleantrueShow the fullscreen button
showAutoHideToggleBooleantrueShow the auto-hide controls toggle button
transitionString'fade'Transition effect: 'fade' or 'slide'
useHrefBooleanfalseRead image URL from href instead of data-src
maxZoomScaleNumber3Maximum zoom scale multiplier
zoomStepNumber0.1Zoom increment per scroll wheel step
animationDurationNumber300Transition animation duration in milliseconds
closeOnBackgroundClickBooleantrueClose lightbox when clicking the dark overlay
autoHideEnabledBooleanfalseStart with auto-hide controls enabled
autoHideDelayNumber3000Milliseconds of inactivity before controls hide
onOpenFunctionnullCallback fired when the lightbox opens
onCloseFunctionnullCallback fired when the lightbox closes
onNextFunctionnullCallback fired when navigating to the next item
onPrevFunctionnullCallback fired when navigating to the previous item

Setting Options at Initialisation

Pass all your options once when creating the instance:

const lightbox = new Zoomora({
  selector: '[data-zoomora]',
  transition: 'fade',
  animationDuration: 400,
  showCounter: true,
  showThumbnails: true,
  showZoom: true,
  showFullscreen: true,
  showAutoHideToggle: false,
  closeOnBackgroundClick: true,
  maxZoomScale: 3,
  autoHideEnabled: false,
  autoHideDelay: 3000,
  onOpen: (element, index) => {
    console.log('Opened:', index);
  },
  onClose: (index) => {
    console.log('Closed at:', index);
  }
});

Updating Options After Initialisation

Use updateOptions() to change options on a live instance without reinitialising:

const lightbox = new Zoomora();

// Later — update one or more options
lightbox.updateOptions({
  transition: 'slide',
  closeOnBackgroundClick: false
});

Only the options you pass are updated. Everything else stays as it was.

Note that updateOptions() does not re-render the lightbox DOM — options like showZoom and showThumbnailsthat affect the HTML structure must be set at initialisation time to take effect correctly.


Using Multiple Instances

If you need different configurations for different sets of images on the same page, create multiple instances with different selectors:

// Minimal lightbox for hero images
new Zoomora({
  selector: '[data-zoomora="hero"]',
  showCounter: false,
  showThumbnails: false,
  showAutoHideToggle: false
});

// Full-featured lightbox for the main gallery
new Zoomora({
  selector: '[data-zoomora="gallery"]',
  transition: 'slide',
  autoHideEnabled: true,
  autoHideDelay: 4000
});

Each instance manages its own set of elements and has its own lightbox overlay. Both can be open independently — though in practice only one is visible at a time since each locks body scroll on open.


Default Values

If you want to inspect the full defaults object in code, access it via the static property:

console.log(Zoomora.defaults);

This returns the complete defaults object and is useful when building wrapper utilities or debugging configuration issues.


Next Step

The following articles cover each configuration group in detail with examples for the most common use cases:

  • Display Options — showCountershowThumbnailsshowZoomshowFullscreenshowAutoHideToggle
  • Behaviour Options — transitionanimationDurationcloseOnBackgroundClickmaxZoomScale
  • Auto-Hide Controls — autoHideEnabledautoHideDelayshowAutoHideToggle
  • Callbacks — onOpenonCloseonNextonPrev

On This Page