Reputation: 616
I'm using the Forge Viewer on an Angular 5 application.
Is there a way to completely unload the viewer so it can later be reloaded?
I have the following code to unload the viewer:
if (this.viewer && this.viewer.running) {
this.viewer.tearDown();
this.viewer.finish();
this.viewer = null;
}
And I also have the code to load the viewer every time the user enters the page.
Currently, when a user navigates to a different page on the application, that code gets executed, but when the user comes back to the page that contains the viewer, it shows a grey box where the viewer should be.
Here's a github repo that reproduces the issue: https://github.com/theivanaguilar/forge-viewer-reload
Am I missing something here?
Upvotes: 2
Views: 1810
Reputation: 4375
The static method Autodesk.Viewing.Initializer
can only be called once the subsequent times it will not return. All other viewer methods need to be invoked every time your component loads. So you need to refactor your code a bit.
My app is using React and I save a boolean in the appState to avoid calling that Initializer twice if it has been initialized already.
Hope that helps
Upvotes: 2