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.

on window resize scale

See original GitHub issue

Here is how I do when window is resized (not a bug) it’s just to share (AND if you have a better way let me know 😃

    jsvmap = new JsVectorMap({
        //...
    });

    // window on resize
    var resizeMapTimer;
    window.addEventListener('resize', function(e) {
        clearTimeout(resizeMapTimer);
        resizeMapTimer = setTimeout(function() {
            jsvmap.height = window.innerHeight;
            $("#map svg").setAttribute("height", window.innerHeight);
            jsvmap.width = window.innerWidth;
            $("#map svg").setAttribute("width", window.innerWidth);
            jsvmap.baseScale = 1;
            //console.log(jsvmap);
        }, 250);
    });

    // Trigger resize event one time at start
    if (typeof(Event) === 'function') {
        // modern browsers
        window.dispatchEvent(new Event('resize'));
    } else {
        // for IE and other old browsers
        // causes deprecation warning on modern browsers
        var evt = window.document.createEvent('UIEvents'); 
        evt.initUIEvent('resize', true, false, window, 0); 
        window.dispatchEvent(evt);
    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
hanc2006commented, Jul 30, 2020

@themustafaomar I forked your pen example, now seem to work right 👍 @panpansh look at this simple responsive map

0reactions
themustafaomarcommented, Jul 14, 2020

Unfortunately, I won’t be able to find a solution currently as time is not on my side 😦 However, I’ll leave this issue opened until I come :]

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scale down / up every html element when window resize
I would like to keep the same layout instead of responsive, but scale up / down everything when I resize the window screen....
Read more >
Window: resize event - Web APIs | MDN
The resize event fires when the document view (window) has been resized. This event is not cancelable and does not bubble.
Read more >
Implement responsive aspect ratio on window resize ... - Daily.co
Use CSS, JavaScript, or React hooks to style your Daily Prebuilt iframe to responsively maintain aspect ratio dimensions on window resize.
Read more >
Scale in horizontal and vertical direction on window resize
On horizontal window resize the mesh always stays completely visible due to rescaling. On horizontal scaling the mesh does not scale. My feature ......
Read more >
Resizing a Three.js Scene When the Browser Window Size ...
I'm going to add an window resize event listener that executes a function when the browser window resizes. This function then updates the...
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