Universal loader that dynamically imports and renders any IMS widget based on the imsType field in the source data. Also serves as the hypermedia navigation container when combined with ims-hotspots.
<ims-viewer src-data="path/to/data.json"></ims-viewer>With hotspots:
<ims-viewer src-data="spinner.json" hotspots="shop-hotspots.json"></ims-viewer>- Fetches JSON from
src-dataURL - Reads
imsType(e.g."spinner","gallery","diff") - Dynamically imports the widget module via
url-template - Creates
<ims-{imsType}>element, passessrc-dataas blob URL - If
hotspotsattribute is set, creates<ims-hotspots>overlay inside the widget
| Attribute | Description |
|---|---|
src-data |
URL to JSON config (must contain imsType field) |
url-template |
ES module URL pattern. Placeholders: {{version}}, {{imsType}} |
version |
Override version for CDN URL (default: from source data or latest) |
hotspots |
URL to hotspot config JSON (see hotspots.md) |
cast-next |
Marker — all attributes after this are forwarded to child widget |
https://cdn.jsdelivr.net/npm/immersive-media-spots@{{version}}/{{imsType}}/+esm
Override for local development:
<ims-viewer
src-data="../spinner/test-data.json"
url-template="../{{imsType}}/index.js">
</ims-viewer>When hotspots is set, the viewer handles hotspot click events:
targetSrcData— pushes current state to history, loads new widget + hotspotsurl— opens external linkaction— calls method on child widget
A back button (←) appears when navigation history is non-empty.
spinner.json ──hotspot──▶ pano.json ──hotspot──▶ gallery.json
│
← back ◀─────┘
<ims-viewer
src-data="../spinner/test-data.json"
url-template="../{{imsType}}/index.js"
cast-next
autoplay="true"
no-ui>
</ims-viewer>All attributes after cast-next (autoplay, no-ui) are set on the child widget.
Style the viewer container or the child widget directly:
ims-viewer {
width: 640px;
height: 400px;
}Back button uses --ims-hotspot-bg and --ims-hotspot-bg-hover tokens.
| Method | Description |
|---|---|
goBack() |
Navigate to the previous view in the history stack |
goHome() |
Navigate to the initial (first) view, clearing all history |
Hotspot navigation fires ims-hotspot-click (see hotspots.md). Standard lifecycle events are emitted by the child widget (see events.md).