Shoji API Reference
    Preparing search index...

    Class Gallery

    Core lifecycle (DESIGN.md §2.2), item model / DOM scanning (§2.1), and the lightbox itself: pooled slides (§2.3), dialog semantics/focus trap/live region (§2.6, non-optional), gestures (§2.4, via GestureController) and slide-to-slide transitions (§2.5, via SlideTransition).

    Index
    options: GalleryOptions = {}

    Not readonly — reinit() (§2.7) reassigns this + every option-derived field below; initializers here just satisfy strict-init.

    element: HTMLElement
    • get isOpen(): boolean

      True from the first open() until close()/destroy().

      Returns boolean

    • get isDestroyed(): boolean

      True once destroy() has run.

      Returns boolean

    • get controlsHidden(): boolean

      Whether auto-hide (§2.8) currently has controls faded.

      Returns boolean

    • DESIGN.md §2.7 — the live instance mounted on el, or undefined if none exists there (or it's since been destroyed).

      Parameters

      • el: HTMLElement

      Returns Gallery | undefined

    • Names of plugins that actually initialized.

      Returns string[]

    • The active slide's .shoji-slide-media container. Empty before the first open(); null only after destroy().

      Returns HTMLElement | null

    • DESIGN.md §4-zoom — suspends drag-to-navigate/close while zoomed. Single slot, not a multi-subscriber event.

      Parameters

      • isZoomed: () => boolean

      Returns () => void

    • DESIGN.md §2.6a/§4.6 — returns the zoomed image's current on-screen rect (getBoundingClientRect()), or null when not zoomed. Single slot, same pattern as registerZoomGate above.

      Parameters

      • provider: () => Box | null

      Returns () => void

    • DESIGN.md §2.5/§4.5 — called once per navigation with the leave- ghost's clone, right after SlideTransition creates it. Freeze whatever per-slide visual state is about to be reset onto the clone (or a descendant, e.g. Zoom's own <img>) and return a () => void to trigger the transition back to neutral once committed — or return nothing if there's nothing to animate away this time.

      Parameters

      • decorator: (clonedMedia: HTMLElement) => void | (() => void)

      Returns () => void

    • The thumbnail for index — what the zoom transition animates to/from, and what activeThumbnail marks/scrolls-to. data-shoji-id is an explicit opt-in that works in any mode (needed for dynamic mode, which has no scanned DOM); checked first so it can override selector mode's default scannedElements[index] too, e.g. to target an inner element.

      Parameters

      • index: number

      Returns HTMLElement | null

    • Lets a plugin's background-page scrollIntoView() survive close()'s scroll restore, routed through this shared instance rather than importing bodyScrollLock directly — required for the standalone core+plugins distribution, where a direct import would get its own disconnected module copy (DESIGN.md §4.2/§10). Same reasoning getOriginElement/getActiveMedia were made public for.

      Returns void

    • Forces the same fade §2.8's idle timer would eventually trigger — public so a plugin can hide controls on its own trigger. Same isControlActive() guard as the timer. Also a no-op under autoHideDelay: false — a real bug, reported from real usage: Autoplay's tap-to-toggle-chrome behavior called this directly and ignored false entirely, since only the idle timer checked it. false has to hold for every caller, not just the timer. forceHideControls()/ setControlsHiddenForDrag() (close, drag-to-close) deliberately don't check this — direct user actions with their own feedback, not auto-hide.

      Returns void

    • Parameters

      • index: number = ...

      Returns void

    • DESIGN.md §2.2/§2.6 — navigates while open; always clamps an explicit out-of-range index (this is a directed jump, not a step — loop only affects next()/prev(), see below). No-op if not open. animate (default true) runs the configured §2.5 transition; hosts that want an instant jump — e.g. syncing to an external index without a visual flourish — can pass { animate: false }.

      Parameters

      • index: number
      • Optionaloptions: { animate?: boolean }

      Returns void

    • DESIGN.md §2.1 — diffs by id (fallback src), preserving the active slide.

      Parameters

      • items: GalleryItemInput[]
      • OptionalcurrentIndex: number

      Returns void

    • Sugar over updateSlides() for the common "insert some items" case — splices items into a copy of the current list at atIndex (default: append at the end) and hands the result to updateSlides(), which still does all the real work (active-item preservation, live re-render if open, itemsUpdated). atIndex follows Array.prototype.splice's own semantics (negative counts from the end, out-of-range clamps) — no extra validation on top of that.

      Parameters

      • items: GalleryItemInput[]
      • OptionalatIndex: number

      Returns void

    • Sugar over updateSlides() for the common "remove some items" case. Accepts a single id/index or an array mixing both: a string matches the same id ?? src key updateSlides() already uses for active-item preservation, a number matches that position in the current items list (resolved against the list as it is now, before any removal — passing [0, 1] removes the first two items, not "index 0, then whatever became index 1 after that").

      Parameters

      • match: string | number | (string | number)[]

      Returns void

    • DESIGN.md §2.7 — selector-mode only; sugar over updateSlides() sourced from a DOM rescan.

      Returns void

    • DESIGN.md §2.7 — full teardown + reconstruction on this, not a new object: Shoji.getInstance(el)/any held reference keeps working across the call, unlike destroy() + new Shoji(...). Omit options to rebuild unchanged (a hard reset); pass options to reconfigure structurally. gallery.on(...) listeners do NOT survive — the event bus is fully cleared, same as destroy() — re-on() anything needed.

      Parameters

      Returns void