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.

Handle parent component width and height change

See original GitHub issue
  <div v-bind:style="windowStyle">
    <vue-draggable-resizable
      v-if="true"
      :parent="true"
      :w="1120"
      :h="500"
    >
      <dashboard/>
    </vue-draggable-resizable>
 </div>

After changing windowStyle the drag is still blocked by the prev windowStyle size.

How can I sync the children with the new size? Thank you

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
mislandcommented, Apr 27, 2020

@MaxYYYYY for me,it doesn’t work,because re-mount the components need some time,so I change the code like this:

this.parentShow = false;
      let _this = this;
      setTimeout(() => {
        _this.parentShow = true;
      }, 100);
2reactions
StreakingMancommented, Mar 14, 2020
<div v-if="parentShow"  v-bind:style="windowStyle">
    <vue-draggable-resizable
      v-if="true"
      :parent="true"
      :w="1120"
      :h="500"
    >
      <dashboard/>
    </vue-draggable-resizable>
 </div>
watch: {
    windowStyle() {
       this.parentShow = false;
       this.parentShow = true;
    }
}

@gsaada it works for me. actually it makes component mount again, the parent element avoid re-render so everything looks normal

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get parent width/height in React using Hooks?
I think useCallback is what you want to use so you can get the width and height when it changes. const [height, setHeight]...
Read more >
Sizing items in CSS - Learn web development | MDN
If you place an image on a page and do not change its height or width, either by using attributes on the <img>...
Read more >
useElementSize() returns 0 width/height if initially rendered ...
For my use case, having a non-zero size reported once the parent is hidden isn't a problem, though reporting a size of 0x0...
Read more >
Why can a child element have a bigger width or height than ...
Imagine the parent element as a window, not a container. The content that you see through the window might be much larger than...
Read more >
Make text fit its parent size using JavaScript
We can "try" to increase the font size step-wise by 1 pixel and test again, whether the element is overflowing it's parent or...
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