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

108
Views
Firefox browser offsetX/Y

const $test = document.querySelector('.test');

function sleep() {
  return new Promise(resolve => {
    setTimeout(() => {
      resolve();
    }, 300);
  });
}
$test.addEventListener('mousedown', async e => {
  console.log(e.offsetX, e.offsetY); // (90, 163) any other values but not 0
  await sleep();
  console.log(e.offsetX, e.offsetY); // 0 0
});
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.test {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  background-color: aqua;
}
<div id="app">
  <div class="test"></div>
  <!-- <canvas width="300" height="300" class="test"></canvas> -->
</div>

#Note It's alright in Google browser, but there has an error in Firefox browser.

  1. The offsetX/Y has value before sleeping.
  2. The offsetX/Y's value become 0.

Can anyone tell me why?

about 4 years ago · Juan Pablo Isaza
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!