How to fix zooming to the cursor after resizing the Speckle Viewer?

I’ve noticed an issue with zoom behavior after resizing the viewer. When I call:

instance.resize(); // instance: Viewer

It seems that the zoom still operates based on the old camera center. For example, if I place my mouse pointer in the middle-left of the screen and zoom in, instead of zooming towards the cursor position, the model zooms towards the (probably old) scene center.

I suspect that I need to adjust orbit controls properly after resizing, but I’m not sure how to do this here.

What’s the correct way to ensure that zooming follows the cursor position after resizing the viewer?

1 Like

Hi @Vitalii

Simply calling resize will not break zooming to cursor on it’s own. There is no need to anything extra to the camera controls. I have a feeling this happens on specific page layouts/setups where the viewer is part of a more complicate(or not) hierarchy of elements.

We would need an example that reproduces the issue. Maybe a stackblitz live example?

Cheers

1 Like

Actually, as it turns out, the problem is not with the resize() method. The issue is that my parent container is relative. (I made it relative because I have many tools that must be positioned absolute within this container).
But how can position break the viewer?

Here is an example

Thank you very much for the example!

We’ve fixed the issue and it will be available soon in our next release!

Thanks again for reporting the issue and providing us with a means to reproduce it! We appreciate the help! :smiley_spockle:

Cheers

Thanks!

When will I approximately be able to access the new release?

Version 2.23.11 has been published and should contain the fix that you are looking for

Thanks a lot for the quick help and getting the fix out so fast – really appreciate it!