Skip to content

Commit

Permalink
fix resize
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoHamuy committed Oct 6, 2023
1 parent 3e5a2c9 commit 7f92c17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-feet-buy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-three-map": patch
---

Fix ThreeJS sync on Mapbox resize.
18 changes: 5 additions & 13 deletions src/core/use-on-add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,11 @@ export function useOnAdd(
if (!r3mRef.current.map) return;
if (!r3mRef.current.state) return;
const canvas = r3mRef.current.map.getCanvas();

if (canvas.classList.contains('mapboxgl-canvas')) {
// if mapbox
r3mRef.current.state.size.width = canvas.clientWidth;
r3mRef.current.state.size.height = canvas.clientHeight;
} else {
// if maplibre
r3mRef.current.state.setSize(
canvas.clientWidth,
canvas.clientHeight,
false
);
}
r3mRef.current.state.setSize(
canvas.clientWidth,
canvas.clientHeight,
false
);

})

Expand Down

0 comments on commit 7f92c17

Please sign in to comment.