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.

Maintain zoom level and center on window / viewer resize

See original GitHub issue

Is it possible to maintain zoom level and center of viewport when we scaling browser window / viewer size? I have an application which need to keep zoom level and center remain same even when users resize the window, because my application synchronize OSD viewport to all connected users trough socket.io. It is look strange when there is user who resize window then send signal zoom and pan in OSD resize event way and will give unnecessary disrupt other users viewport.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
avandecremecommented, Jun 20, 2016

The relevant code is here https://github.com/openseadragon/openseadragon/blob/master/src/viewer.js#L2988-L3009

It doesn’t look like there is a good event you can listen to to tweak the behavior. For now, you can try to modify that code like this and see if that works for you. We can figure out a better approach afterward.

    if (viewer.autoResize) {
        var containerSize = _getSafeElemSize(viewer.container);
        var prevContainerSize = THIS[viewer.hash].prevContainerSize;
        if (!containerSize.equals(prevContainerSize)) {
            var viewport = viewer.viewport;
            var center = viewport.getCenter();
            viewport.resize(containerSize, false);
            viewport.panTo(center, true);
            THIS[viewer.hash].prevContainerSize = containerSize;
            THIS[viewer.hash].forceRedraw = true;
        }
    }
0reactions
bayucandracommented, Jun 22, 2016

@iangilman yes, you are right. It could be another alternative solution for my problem. @avandecreme that sounds good, it is new for me about viewportToImageZoom. @iangilman also mention about that function previously, but still not sure yet how i will manage it for my problem. Will make some experiment about that later.

Thanks a lot for both of you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Zoom advanced options for accessibility on Mac
Change the size and position of the zoom window while working using the indicated keyboard shortcuts. Set the maximum and minimum levels of...
Read more >
How do I keep images zoomed at the same level when ...
Zoom to the desired level and position. On the IrfanView menu bar, select View->Lock Zoom (Shift+L) and View->Keep Scroll position; Browse other images....
Read more >
Adjusting your video layout during a virtual meeting
Customize your video layout preferences during your Zoom meetings—see everyone, hide participants, and much more.
Read more >
Google maps set different zoom based on window resize
The following code works perfectly in regards of recentering the map on windows resize, I need to apply the new zoom levels to...
Read more >
Zoom level inside Edge is much higher than is indicated
I use Windows 10 with 100% of scale set in Display and all text in ... But inside Edge viewer with indicated 100%...
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