@ebay/ebayui-core
Version:
Collection of core eBay components; considered to be the building blocks for all composite structures, pages & apps.
39 lines (38 loc) • 971 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const model_viewer_1 = require("@internal/model-viewer");
class Viewer {
handleError(err) {
this.state.failed = true;
this.state.isLoaded = true;
this.emit("load-error", err);
}
onCreate() {
this.state = {
showLoading: false,
isLoaded: true,
failed: false,
};
}
handleSuccess() {
this.state.isLoaded = true;
this.state.showLoading = false;
this.state.failed = false;
}
onMount() {
this.viewer = this.getEl("3d-viewer");
this._loadViewer();
}
_loadViewer() {
this.state.failed = false;
this.state.isLoaded = false;
(0, model_viewer_1.load)()
.then(() => {
this.handleSuccess();
})
.catch((e) => {
this.handleError(e);
});
}
}
module.exports = Viewer;