Search code examples
autodesk-forgeautodesk-viewer

Forge Viewer: VIEWER_RESIZE_EVENT raise all the time


Im using VIEWER_RESIZE_EVENT to catch when viewer resize but it raise all the time even it doesnt has any change (take a look attached pic). And when i use that method, objects do not highlight when mouse move over anymore. I solved the problem by different way is catch resize div event, it works perfectly. SoVIEWER_RESIZE_EVENT really has a problem or i misunderstand how to use it? Appreciated any comments.

resize event problem


Solution

  • The VIEWER_RESIZE_EVENT definitely shouldn't be called all the time. Such a behavior is usually a sign of some problematic JavaScript code where, for example, some piece of code reacts to this event and (accidentally or intentionally) causes some change in the viewer size, causing an infinite loop of resize events.

    When you try any of the official sample apps, you'll see that the event is really only triggered when the viewer canvas size actually changes.