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.

Forcing width when resizing

See original GitHub issue

Hi!

I looked over similar questions but none of the answers work for me, so. My problem is simple: I want to enforce specific width in @resizing event. The point is for the object being resized to be constrained by its parent, but setting :parent prop doesn’t work for me. Maybe because the parent is a table cell, so my resizable blocks appear somewhere else but not in cells when I set parent restriction. But anyway, I also support dragging between cells, so restricting it to parent won’t work for me.

So I wanted to implement the constraint manually, but changing :width in @resizing event doesn’t do anything. Could you give me some advice on how to change object’s width so that when user is resizing it, the width won’t go over the specific value (will be forced to stay at some max value that is dynamically calculated).

Thanks!

P.S. Setting maxwidth won’t do as well because my object may be placed for example in a middle of a cell. So then user would resize to the right and maxwidth will go over the cell’s border.

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
libid0nescommented, May 4, 2020

w and h are reactive props, but they are disabled during dragging or resizing

Please specify this point in the documentation, I spent an hour before I found this thread.

2reactions
mauriciuscommented, Mar 1, 2020

Hi!

First of all, thank you for reporting the issue with this level of details. Much appreciated!

changing :width in @resizing event doesn’t do anything

w and h are reactive props, but they are disabled during dragging or resizing because otherwise they would interfere with the internals of the component. I know that this is not the best idea and often it causes confusion, but I’m afraid that solving this problem would require a huge rewrite of the component.

Back to your problem: there’s no way right now to force a specific width during resizing or dragging, but you can use the resizestop and dragstop events to revert the size of the component to the desired values.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS force image resize and keep aspect ratio - Stack Overflow
You can adjust the width and height to fit your needs, and the object-fit property will do ... Just setting one will resize...
Read more >
Resize Images Proportionally While Keeping The Aspect Ratio
Use max-width: 100% to limit the size but allow smaller image sizes, use width: 100% to always scale the image to fit the...
Read more >
resize - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The resize CSS property sets whether an element is resizable, and if so, in which directions.
Read more >
3 Ways to Keep Image Aspect Ratio In HTML CSS - Code Boxx
To maintain the aspect ratio of images in CSS, the easiest way is to manually set the dimension of the width, then the...
Read more >
Preserve an Image's Aspect Ratio When Resized | kirupa.com
By setting the width property to 100%, you are telling the image to take up all the horizontal space that is available.
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