Skip to content

Commit

Permalink
fix: camera state when hidden page is rendered (#1819)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
w1nklr and nilscb authored Dec 8, 2023
1 parent 49a74b7 commit 422325e
Show file tree
Hide file tree
Showing 16 changed files with 592 additions and 279 deletions.
15 changes: 7 additions & 8 deletions typescript/packages/subsurface-viewer/src/SubsurfaceViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ export interface SubsurfaceViewerProps {
id: string;
resources?: Record<string, unknown>;
layers?: Record<string, unknown>[] | LayersList;

bounds?: [number, number, number, number] | BoundsAccessor;
cameraPosition?: ViewStateType | undefined;
triggerHome?: number;

views?: ViewsType;
coords?: {
visible?: boolean | null;
Expand Down Expand Up @@ -96,10 +100,6 @@ export interface SubsurfaceViewerProps {
onDragStart?: (info: PickingInfo, event: MjolnirGestureEvent) => void;
onDragEnd?: (info: PickingInfo, event: MjolnirGestureEvent) => void;

/**
* If changed will reset camera to default position.
*/
triggerHome?: number;
triggerResetMultipleWells?: number;
/**
* Range selection of the current well
Expand All @@ -113,7 +113,6 @@ export interface SubsurfaceViewerProps {
* Override default tooltip with a callback.
*/
getTooltip?: TooltipCallback;
cameraPosition?: ViewStateType | undefined;

lights?: LightsType;

Expand All @@ -125,6 +124,8 @@ const SubsurfaceViewer: React.FC<SubsurfaceViewerProps> = ({
resources,
layers,
bounds,
cameraPosition,
triggerHome,
views,
coords,
scale,
Expand All @@ -136,12 +137,10 @@ const SubsurfaceViewer: React.FC<SubsurfaceViewerProps> = ({
onMouseEvent,
selection,
getTooltip,
cameraPosition,
getCameraPosition,
isRenderedCallback: isRenderedCallback,
isRenderedCallback,
onDragStart,
onDragEnd,
triggerHome,
triggerResetMultipleWells,
lights,
children,
Expand Down
Loading

0 comments on commit 422325e

Please sign in to comment.