Skip to content
OGE logoOGE

Image Viewer API

Full surface of oge-image-viewer: its inputs, methods and outputs, the interaction model and the config provider.

Properties Methods Events Types

OgeImageViewer

oge-image-viewer

Properties 7

Name Type DefaultDescription
imagesreadonly OgeImageViewerItem[] (required)—The gallery. Fields: src, alt (read out, and shown when the file fails), caption? (under the image), thumbnail? (a smaller file for the strip, default src). A new array keeps the index when it still fits.
indexnumber (model)0The shown image — two-way. Changing image resets zoom, pan and rotation.
loopboolean | undefinedconfig ?? falsePages from the last image to the first and back (buttons, keys, thumbnails stay direct).
maxZoomnumber | undefinedconfig ?? 8Largest zoom factor (8 = 800 %). Zoom steps through 1, 1.5, 2, 3, 4, 6, 8; the wheel and pinch zoom smoothly, always around the pointer.
thumbnailsbooleantrueThe thumbnail strip under the image — shown for two images or more; the current one carries aria-current.
toolbarbooleantrueThe toolbar: previous / counter / next, zoom out / level / zoom in / fit, rotate left / right and full screen. Without it the keyboard, the wheel, a double click and pinch still work.
messagesPartial<OgeImageViewerMessages>{}Per-instance overrides of the config catalog.

Methods 3

Name Type Description
next()() => voidShows the next image (wraps only with loop).
previous()() => voidShows the previous image (wraps only with loop).
resetView()() => voidBack to fit: zoom 1, no pan, no rotation.

Events 2

Name Type Description
indexChangenumberThe banana half of [(index)].
zoomChangenumberThe zoom factor changed (1 = fit) — from the toolbar, the keys, the wheel, a double click (fit ↔ 2×) or a two-finger pinch.

Types 6

Interaction

Name Type Description
Keyboardrole="group", tabindex="0"With focus on the viewer: Arrow Left / Right page (they pan while zoomed, as do Up / Down), Home / End and Page Up / Down jump, + / - zoom, 0 fits, R / Shift+R rotate and F toggles full screen. A polite live region announces each image.
Pointerdrag · wheel · double click · pinchWhile zoomed, dragging pans (clamped so the image never leaves the stage); the wheel zooms, a double click toggles fit and 2×, two fingers pinch. Full screen uses the Fullscreen API and follows fullscreenchange, so Esc keeps the state in sync.
OgeImageViewerIteminterfaceOne image: src, alt (read out, and shown when the file fails), caption? (under the image), thumbnail? (a smaller file for the strip, default src).
OgeImageViewerCoreclass (@oge-ui/behavior)The framework-free state machine both render layers drive: index, zoom, pan, rotation, full screen and the key map.
OgeImageViewerCoreOptions{ reactivity; messages; onIndexChange?; onZoomChange?; requestFullscreen? }What the core takes: a reactivity adapter, the catalog, and the callbacks a render layer wires to its outputs and to the Fullscreen API.
OGE_IMAGE_ZOOM_STEPSreadonly number[]The zoom stops of the buttons and keys.

Configuration

Properties 2

provideOgeImageViewerConfig()

Name Type Description
messagesOgeImageViewerMessagesEvery user-facing string: label, previous, next, zoomIn, zoomOut, resetZoom, rotateLeft, rotateRight, fullscreen, exitFullscreen, thumbnails, empty, and the templates counter ({index} of {count}), zoomLevel ({zoom}%) and announce ({alt}, image {index} of {count}, the live-region text). Translated in every @oge-ui/locales pack (layout.imageViewer).
loop / maxZoom—Defaults for the matching inputs. Pass a function for a live config.

Types 8

Name Type Description
provideOgeImageViewerConfig(config: OgeImageViewerConfigInput | (() => OgeImageViewerConfigInput)) => ProviderApplication- or component-scoped defaults; a function makes the config live.
OGE_IMAGE_VIEWER_CONFIGInjectionToken<OgeImageViewerConfig>The resolved config the viewer injects.
OGE_DEFAULT_IMAGE_VIEWER_CONFIGOgeImageViewerConfigThe defaults (from @oge-ui/behavior).
OGE_DEFAULT_IMAGE_VIEWER_MESSAGESOgeImageViewerMessagesThe English catalog.
resolveOgeImageViewerConfig(input?, base?) => OgeImageViewerConfigMerges a partial config over a base (the defaults).
OgeImageViewerConfig{ messages: OgeImageViewerMessages; loop?: boolean; maxZoom?: number }Resolved config shape.
OgeImageViewerConfigInputPartial<OgeImageViewerConfig> with partial messagesWhat the provider accepts.
OgeImageViewerMessages{ label; previous; next; zoomIn; zoomOut; resetZoom; rotateLeft; rotateRight; fullscreen; exitFullscreen; thumbnails; counter; zoomLevel; announce; empty }The image viewer catalog.