iframe Events
This page describes the events the host page can listen for on the iframe DOM element.
How to Listen
js
iframe.addEventListener('eventName', (event) => {
console.log(event.detail);
});Except for the browser-native load / error events, plugin events are dispatched as CustomEvent, and business data is read from event.detail.
Event List
| Event name | Scene | Collection | Description |
|---|---|---|---|
load | Supported | Supported | iframe page resources finished loading |
error | Supported | Supported | loading error, permission failure, and so on |
incompatibility | Supported | Supported | preflight compatibility check failed |
ready | Supported | Supported | basic scene or collection information is ready |
downloadAssetStart | Supported | Supported | asset download starts |
downloadAssetProgress | Supported | Supported | asset download progress changes |
downloadAssetEnd | Supported | Supported | asset download completes |
loadSceneStart | Supported | Supported | scene content starts loading |
loadSceneEnd | Supported | Supported | scene content finishes loading |
sceneStart | Supported | Supported | scene starts and the user can enter the experience |
tracked | Supported | Supported | target tracked successfully |
lostTrack | Supported | Supported | target tracking lost |
openUrl | Supported | Supported | webpage jump triggered |
sceneReady | Not supported | Supported | a concrete scene inside the collection is ready |
sceneDestroy | Not supported | Supported | previous scene is destroyed before switching |
load
ts
type LoadEvent = EventIndicates that iframe page resources are loaded. It does not mean assets are finished downloading.
error
ts
interface PluginErrorDetail {
message: string;
code?: number;
isCameraNotFound?: boolean;
isUserDeniedCamera?: boolean;
isUserDeniedGyroscope?: boolean;
}It may also be a plain string.
If the browser's native error event fires instead, the payload is the browser's Error event object.
incompatibility
ts
type IncompatibilityDetail = Record<string, any>The payload shape is not fully fixed for now. Common cases include:
- the current browser is not suitable for opening the camera
- the current mode is unavailable on this client
ready
Scene
ts
interface SceneInfo {
sceneId: string;
name: string;
description: string;
thumbnailUrl: string;
type: string;
collectionId: string;
collectionName: string;
firstPage: {
backgroundImageUrl?: string;
logoUrl?: string;
buttonUrl?: string;
hideLogoAndName?: boolean;
hideLogoAndSceneName?: boolean;
};
metadata: {
htmlTitle?: string;
share?: {
title?: string;
description?: string;
picture?: string;
pictureUrl?: string;
};
};
setting: {
skipScanMarker?: boolean;
scanImage?: string;
scanText?: string;
hideScanImage?: boolean;
userMarker?: string;
};
objects: Array<{
id: number;
name: string;
type: string;
}>;
}
interface SceneReadyDetail {
sceneInfo: SceneInfo;
api: SceneApi;
}Collection
ts
interface CollectionInfo {
collectionId: string;
name: string;
description: string;
thumbnailUrl: string;
functionType: string;
firstPage: {
backgroundImageUrl?: string;
buttonUrl?: string;
hideLogoAndName?: boolean;
};
sceneList: string[];
setting: {
continue_scan?: number;
};
}
interface CollectionReadyDetail {
collectionInfo: CollectionInfo;
api: object;
}downloadAssetStart
ts
type DownloadAssetStartDetail = undefineddownloadAssetProgress
ts
type DownloadAssetProgressDetail = numberValue range: 0.0 - 1.0.
downloadAssetEnd
ts
type DownloadAssetEndDetail = undefinedloadSceneStart
ts
type LoadSceneStartDetail = undefinedloadSceneEnd
ts
type LoadSceneEndDetail = undefinedsceneStart
ts
type SceneStartDetail = undefinedtracked
ts
type TrackedDetail = undefinedlostTrack
ts
type LostTrackDetail = undefinedopenUrl
ts
type OpenUrlDetail = stringdetail is the URL about to be opened.
sceneReady
Collections only.
ts
interface SceneReadyDetailInCollection {
sceneInfo: SceneInfo;
api: SceneApi;
}sceneDestroy
Collections only.
ts
interface SceneDestroyDetail {
sceneId: string;
}Event Order
Scene
text
load
-> ready
-> downloadAssetStart
-> downloadAssetProgress
-> downloadAssetEnd
-> loadSceneStart
-> loadSceneEnd
-> sceneStartCollection
text
load
-> ready
-> sceneReady
-> downloadAssetStart
-> downloadAssetProgress
-> downloadAssetEnd
-> loadSceneStart
-> loadSceneEnd
-> sceneStart