Skip to content

Commit

Permalink
added resize handle
Browse files Browse the repository at this point in the history
  • Loading branch information
pieterprovoost committed Sep 5, 2024
1 parent 40df30c commit 26f75b3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,21 @@ function App() {

const groupRef = useRef();

const ensureResize = function(mapRef) {
const resizeObserver = new ResizeObserver(() => {
mapRef.invalidateSize();
});
const container = document.getElementById("map");
if (container) {
resizeObserver.observe(container);
}
}

const displayMap = useMemo(
() => (
<MapContainer
id="map"
whenReady={(mapRef) => ensureResize(mapRef.target)}
center={[10, 0]}
zoom={1}
scrollWheelZoom={true}
Expand Down
7 changes: 7 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ html, body {
width: 100%;
height: 450px;
background-color: #eeeeee;
resize: vertical;
}

textarea {
Expand All @@ -37,3 +38,9 @@ code {
border: 0 !important;
border-radius: 5px;
}

#map::-webkit-resizer {
background-color: "none";
border-bottom: 4px double black;
padding-right: 20px;
}

0 comments on commit 26f75b3

Please sign in to comment.