xeokit-sdk icon indicating copy to clipboard operation
xeokit-sdk copied to clipboard

Spinner - using a custom spinner result in getting a lost dom element

Open de-buddy opened this issue 8 months ago • 0 comments

Describe the bug

While using the viewer, we use a custom spinner.

But this dom element can get lost/destroyed.

The reason in (dist/xeokit-sdk.es.js Line: 15060....): ´this._isCustom = false;seems to be always false. When_destroy()` is called internally,

Line 15190...
_destroy() {
    if (this._element && (!this._isCustom)) {
              //                 ^^^^^^ custom was used but here never set to something positive. Its always false
              // remove element: in this case also our custom spinner:
        this._element.parentNode.removeChild(this._element);
        this._element = null;
    }
    ...

eg. when re-init the viewer like viewer.destroy(); it drops our custom dom element e.g: <div id="myspinner"...

The next creation of a viewer can not find myspinner in the dom anymore and creates an internal spinner we can not control (in position or layout).

To Reproduce

viewer = new Viewer({
    canvasElement: viewerCanvas,
    transparent: true
    spinnerElementId: "myspinner"
}),

// ... load model/s an show

if (viewer) { 
    viewer.destroy();
}

// create a new viewer
viewer = new Viewer({
    canvasElement: viewerCanvas,
    transparent: true
    spinnerElementId: "myspinner"
}),
ERROR:
    [Spinner '__1']: Can't find given Spinner HTML element: 'myspinner' - will automatically create default element

Desktop (please complete the following information):

  • OS: Current *nix or Win Systems
  • Browser: Any current browser

Kind regards

de-buddy avatar Jun 06 '24 14:06 de-buddy