Skip to content

Examples get scrollbars when resizing the window and custom scaling in the os. #19136

@greggman

Description

@greggman
Description of the problem

II noticed today all the examples currently get scrollbars as I resize them on Windows. Depending on the size they appear and disappear.

Chrome 80

コメント 2020-04-15 133410

Firefox 75

コメント 2020-04-15 133452

I'd like to suggest again that I think the default CSS for the examples should effectively be

html,
body,
canvas {
  margin: 0;
  width: 100%;
  height: 100%;
  display: block;
}

or if you want it separated

html {
  height: 100%;
}
body {
  margin: 0;
  height: 100%;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
}
  • The height: 100% in body is needed to make sure the body covers the entire window
  • The height: 100% in html is needed on firefox

And I'd suggst at a minimum the example code should be changed to

  1. not have a container. AFAICT it has no point

    container = document.createElement( 'div' );
    document.body.appendChild( container );
    ...
    container.appendChild( renderer.domElement );

    to just

    document.body.appendChild( renderer.domElement );

    3 lines to 1

  2. pass false to setSize

        renderer.setSize( window.innerWidth, window.innerHeight, false );

Of course I'd still suggest switching the default to do this all deeper in three and just make CSS the sizing the default and mostly get rid of the need for setSize in most apps as somewhat suggested in #4903

In any case how you fix it or if you fix it is up to you. I just assumed you didn't want scrollbars to appear.

Three.js version
  • Dev
  • r115
  • ...
Browser
  • All of them
  • Chrome
  • Firefox
  • [?] Internet Explorer
OS
  • All of them
  • Windows
  • macOS
  • Linux
  • Android
  • iOS
Hardware Requirements (graphics card, VR Device, ...)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions