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.

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

See original GitHub issue
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, …)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
mrdoobcommented, Jan 7, 2021

Forgot to share here some investigation I did on this issue some months ago: https://github.com/w3c/csswg-drafts/issues/5260#issuecomment-726044922

1reaction
mrdoobcommented, Apr 20, 2020

Looks like changing canvas to display: block introduced this issue. It was all fine when we were using overflow: hidden. I’m partly kidding. I know we were “hiding” the issue 😛

We should definitely do things “the right way” as much as we can, but I was always unsure (and still am) of exposing users to css.

Read more comments on GitHub >

github_iconTop Results From Across the Web

scrollbar - CSS-Tricks
Get started with $200 in free credit! A brief history of styling scrollbars: It used to be a thing only Internet Explorer could...
Read more >
How To Customize the Browser's Scrollbar with CSS
Firstly, we set the .scrollbar (class) width, height, background-color , then set overflow-y: scroll to get the vertical scrollbar.
Read more >
How to Customize the Scrollbars on Windows 10 and 11
To change the Scrollbars height to your liking, enter a value between -120 (smaller) to -1500 (larger) for the size you want, and...
Read more >
Element size and scrolling - The Modern JavaScript Tutorial
As a sample element to demonstrate properties we'll use the one given ... On a Desktop Windows OS, Firefox, Chrome, Edge all reserve...
Read more >
Prevent scroll-bar from adding-up to the Width of page on ...
For example, I have a page (1) with lots of contents that overflows the viewport's (right word?) height, so there's a vertical scroll-bar...
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