Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NGRM] camera settings is wrong when subsurface is first rendered on hidden page #1820

Open
w1nklr opened this issue Dec 7, 2023 · 0 comments

Comments

@w1nklr
Copy link
Collaborator

w1nklr commented Dec 7, 2023

On a page with multiple tabs, each displaying a subsurf viewer, the viewers fail to initialize the view state correctly for the hidden tabs that are rendered tabs that are rendered with prop hidden set to true.

w1nklr added a commit that referenced this issue Dec 8, 2023
Fix for #1820 

Add formal size state and effect to retrieve size from deck ref for code
clarity
Move global bounding box handling to React reducer instead of useEffect.
Move camera computation to useMemo instead of useEffect.
Memoize viewPortMargins and deckGLLayers

Add a new story displaying the subsurface viewer in tabs to reproduce
the issue

Note that this is a first step to reduce the number of useEffect in the
Map component

---------

Co-authored-by: nilscb <nils.christian.bonnevie@gmail.com>
hkfb pushed a commit that referenced this issue Dec 8, 2023
w1nklr added a commit that referenced this issue Dec 18, 2023
Refactor Map component to remove numerous useEffect

Main motivation is to fix wrong view state computed when first rendering
is done with hidden flag.
First reproduced by application with tabbed layout where all the tabs
are rendered using hidden flag.
This use case has been added to the storybook to demonstrate the issue,
along with a 'triggerHome' control (in a previous PR).

The current PR brings:
- onResize() function to handle resizing
- use a React reducer to handle Z scaling
  Add support for PageUp/PageDown and Shift modifier
- use a React reducer to compute the global 3D bounding box from the
reportBoundingBox callback of the layers
- introduce a ViewController class to generate the DeckGL views and
viewState
This brings all the computations in one place/one step by providing
state change allowing to fine-tune the computations
- use bounding box from the 'cameraPosition' (if set as zoom field)
instead of the data bounding box

Fixes:
- initial viewState is correct, even when rendered with 'hidden' flag
set to true
- triggerHome now respects current zScale

In the end, the final implementation drops down to 6 React useEffect,
from the 16 initial ones !



Fix for #1820
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant