Nidium icon indicating copy to clipboard operation
Nidium copied to clipboard

Window resize events, viewport size and fullscreen mode

Open cookiengineer opened this issue 8 years ago • 0 comments

Is there something like a window.onresize = function(){} available on the global object?

When looking at the bindings, I found something like sizeChanged(width, height) that seems to be called, but I couldn't find it somewhere else.

Other ways of resizing the window (setting innerWidth, innerHeight or calling setSize()) seem to fire no event or callback.

My questions are now as follows:

  • Is there a way to get the viewport size (like 1920x1080 when my window is smaller)?
  • If not, is there a way to get resize events of the window when the user maximizes it?
  • Fullscreen mode could be optional, if not wanted - but if so, dependencies would be the previous two points to implement it manually.

Use case could be as follows:

window.addEventListener('resize', function(width, height) {
    console.log('window was resized by user, need to resize my canvas nao');
});


let mybutton = new DummyFullscreenButton();

mybutton.bind('touch', function() {
    if (window.viewportWidth < window.innerWidth || window.viewportHeight < window.innerHeight) {
        window.setSize(window.viewportWidth, window.viewportHeight);
    }
});

cookiengineer avatar Apr 12 '17 14:04 cookiengineer