Why does google chrome devtools emulation pointer offsets gets wrong on fixed elements?
Asked Answered
G

0

8

When I go into chrome devtools and click toggle device toolbar, the touch pointer seem to give a little off coordinates when clicking. It's very subtle but I've noticed a few scenarios where the pointer may be up to 25px off on other sites. This seems to be happen only on fixed elements.

You can test this here: https://jsfiddle.net/pm6avL3n/6/

I run it in ipad pro chrome emulator, point over the number "5" and try click a few pixel right of it and you may get a few pixels off, the X coordinate may return a lower result even if you click a little right of your last click.

Code:

<script>
  document.addEventListener('click',function(e) {
    console.log(e.pageX + ' ' + e.pageY);
  });
</script>

Screenshot: enter image description here

I'm on chrome version: 102.0.5005.115 (Official Build) (64-bit)

The problem only occurs in the emulator, not in actual devices. But we use the emulator when we code, so would like to highlight this. If there is any solution, please let me know. Or if you can confirm this happens to you too, please comment.

Peace and love!

Graecize answered 20/6, 2022 at 15:33 Comment(3)
I am very much frustrated with this. The click on span elements is not working when switching to mobile view. By clicking on very edge on the span it works sometimes. I prefer to use span elements as buttons. This was working fine until I upgraded to latest version on 20th June 2022. Any solutions?Hydrogenolysis
@Hydrogenolysis Thanks for confirming. Please upvote if you have the same problem, maybe this can be more highlighted after all and hopefully to someone working with chrome updates :)Graecize
This still seems to be an issue as of Sep 2023. Quite infuriating...Owner

© 2022 - 2024 — McMap. All rights reserved.