question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Resize of container Issue

See original GitHub issue

Probably related to

So the structure I have is something like this

<style>
.container {
	display: flex;
	flex-flow: row nowrap;
	width: 100vw;
	height: 100vh;
}

aside {
	width: 300px;
	height: 100%;
	transition: width 0.2s ease;
}

aside.collapsed {
	 width: 0px;
}

.map {
	flex: 1 1 auto;
}
</style>


<div class="container">
	<aside>
		<span>controls</span>
	</aside>
	<div class="map">
	</div>
</div>

When I collapse the sidebar, the size of the map doesn’t get updated as it should, I tried forcing a map.resize() when the sidebar is toggled, the problem is that as it has a transition I had to do this

  const sidebarAnimationDuration = 220;
  afterCollapse = () => {
    window.setTimeout(() => {
      window.dispatchEvent(new Event('resize'));
    }, sidebarAnimationDuration);
  };

  setCollapse = collapsed => {
    this.setState({ collapsed }, this.afterCollapse);
  };

Which feels like a messy hack, is there any better way of doing this ?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:12
  • Comments:7

github_iconTop GitHub Comments

2reactions
ro2niecommented, Jun 24, 2021

This is how I made it work, by using a ResizeObserver:

const ro = new ResizeObserver(() => {
    if (map) {
        map.resize();
    }
});

// Observe the map div container.
ro.observe(document.getElementById('map'));

If you are using Angular, you might need a polyfill for ResizeObserver, or just do:

const ro = new (window as any).ResizeObserver(() => {
    if (this.map) {
        this.map.resize();
    }
});

ro.observe(document.getElementById('map'));
2reactions
JClackettcommented, Jul 16, 2020

any update on this? the above solutions dont feel right

Read more comments on GitHub >

github_iconTop Results From Across the Web

how do i fix this resizing issue with my container and div boxes
I want the div and header to resize proportionally when I make it bigger and smaller. The issue is that as I am...
Read more >
Issue with resizing containers in dashboard.
Issue with resizing containers in dashboard. Formatting in Tableau can be painful, and meaningless sometimes. I'm trying to align worksheets in a dashboard ......
Read more >
APFS Container Resizing Issues 49153 - Apple Developer
Running into strange error when attempting to resize a APFS container. Example APFS container is currently 499g with 161g free. Attempted to resize...
Read more >
Can We Create a "Resize Hack" With Container Queries?
The idea is that you could have a container with a resizable element inside it, and then another element that gets fixed positioning...
Read more >
How to Auto-Resize the Image to fit an HTML Container
It is not complicated to make the image stretch to fit the <div> container. CSS makes it possible to resize the image so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found