Lifecycle
When the element starts, starts over and cleans up, including in a single-page app.
<vizbl-core> manages itself: there is nothing to create or destroy by hand.
- It starts when it is on the page and registered. It reads its attributes, loads the model's details and shows the button, which works once
data-stateisreadyandcore-ar-readyhas fired. - It starts over when
type,object-id,variant-id,api-keyor a 3D viewer setting changes. A viewer or AR session of the previous object is closed.trigger-classandunstyledonly restyle the button. - It cleans up when it leaves the page: requests still under way stop, and its viewer or AR session closes.
The 3D viewer and AR load on the first tap that needs them, once for the whole page. Several elements on one page share that code and each keeps its own model and key.
In a single-page app
Render the element with the product and remove it with the product: a route change that unmounts it cleans it up.
The script defines the element once for the whole page. Elements your app adds later, on any route, start by themselves.