Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Why window.innerWidth is wrong?

I'm trying to make a canvas JavaScript game, so i added this in code

window.addEventListener("resize", () => {
  console.log("resi2ze");
  canvasElement.width = window.innerWidth;
  canvasElement.height = window.innerHeight;
});

But when I resize browser window, canvas height is bigger than body height (for example, body height is 465px, and canvas height is 462px). How can I prevent it, so canvas height would be same as window height? image example

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

Seems like the scrollbar itself is an issue, because it adds few pixels. I always add overflow: hidden to body so scrollbar doesn't show up.

about 4 years ago · Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!