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.

Retain scale when resizing

See original GitHub issue

When 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:closed
  • Created 6 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
medihackcommented, Feb 20, 2018

@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:

  • When the image was never zoomed and never panned then always fit the image to the window size.
  • When it was zoomed or panned then do a relative rescale.

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 (from fitToWindow) as it is now used in fitToWindow and resize (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.

1reaction
jdnarvaezcommented, Feb 9, 2018

@dannyrb FWIW I see rads/OR users resize viewports a lot when changing layouts and retaining one of the stacks they were displaying previously.

Read more comments on GitHub >

github_iconTop 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 >

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