Retain scale when resizing
See original GitHub issueWhen calling resize
on an enabledElement
(maybe because the layout changed or the browser window was resized) there currently seems to be no way to retain the scale of the image. When calling resize
with fitViewportToWindow === true
the image is resized to fit the viewport (as expected). Calling it with fitViewportToWindow === false
then the visible part of the image may be cut off (when the resized canvas is smaller). It would be nice if there is a way to show the image in the same way it was presented before the resize
, just larger or smaller.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Maintain or scale stroke width while resizing in Illustrator
To keep stroke width constant, or change (along with other properties) in proportion to objects and text when resizing, go to Edit>Preferences>General –...
Read more >How to Resize an Image Correctly | The TechSmith Blog
When scaling your image, it's crucial to maintain the ratio of width to height, known as aspect ratio, so it doesn't end up...
Read more >How to resize an image in Photoshop and keep best quality
In this tutorial, I'm going to address some things that a lot of people don't know. How to resize an image in Photoshop...
Read more >How to resize images in Photoshop - Adobe Support
If you want to scale the width and height independently of each other, click the Constrain Proportions icon (link icon) to unlink them....
Read more >Resize layers with the scale tool - Figma Help Center
Use the scale tool to proportionally resize layers and objects. This tool preserves aspect ratios and ignores constraints of any nested layers in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dannyrb Yes, @jdnarvaez is right. Especially maximizing/minimizing a view and changing the layout is done very often. And one would expect to retain the correct (or better to say intuitive) scale somehow. I investigated how other DICOM viewers handle this, and it is more complex (and more diverse) than I initially would have thought (funny when I think about how often I use such a viewer at work).
Most viewers behave the following way:
I implemented this in the provided pull request and it seems to feel quite natural (at least I hope so). I extracted the function
getImageSize
in its own file (fromfitToWindow
) as it is now used infitToWindow
andresize
(I had to test somehow in resize if the image fits the window). I also rewrote the resize example to demonstrate the new functionality (just resize the window by dragging the little red square on the right bottom of the window).I would be happy for suggestions and comments.
@dannyrb FWIW I see rads/OR users resize viewports a lot when changing layouts and retaining one of the stacks they were displaying previously.