Issue metadata
Sign in to add a comment
|
getBoundingClientRect return invalid postion when devicePixelRatio != 1
Reported by
achmedzh...@gmail.com,
Sep 11
|
||||||||||||||||||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36
Steps to reproduce the problem:
0. Run Windows 10, change system font size to > 100% (for example 125%)
1. Open simple page with HTML:
<svg>
<g transform="translate(200, 100)" id="fo-g" >
<foreignObject _ngcontent-c18="" pointer-events="all" style="overflow:visible;" width="50" height="50">
<div id="fo-block" >
<span _ngcontent-c18="" class="tag-title-text">Paragraph</span>
</div>
</foreignObject>
</g>
</svg>
And JavaScript
let text = 'g rect \n' + JSON.stringify(document.getElementById('fo-g').getBoundingClientRect());
text += '\n\n';
text += 'foreignObject div rect\n ' + JSON.stringify(document.getElementById('fo-block').getBoundingClientRect());
text += '\n\n';
text += 'window.devicePixelRatio ' + window.devicePixelRatio;
let traceTag = document.createElement('pre');
document.body.appendChild(traceTag)
traceTag.appendChild(document.createTextNode(text));
I created page with jsfiddle https://jsfiddle.net/8u9nvozm/19/
2. See results on the screen.
What is the expected behavior?
Coordinates x,y are not depeneded from DPI. Firefox work well.
What went wrong?
Сoordinates from the method do not match the coordinates on the screen.
Did this work before? No
Does this work in other browsers? N/A
Chrome version: 68.0.3440.106 Channel: stable
OS Version: 10.0
Flash Version:
,
Sep 11
I found workaround: when set zoom=window.devicePixelRatio to the div element then getBoundingClientRect returns correct corrdinates.
,
Sep 11
#882899 is about size, but this issues is about position
,
Sep 11
The underlying issue the same - if it's size or position doesn't really matter.
,
Sep 11
Ok |
|||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||
Comment 1 by f...@opera.com
, Sep 11Status: Duplicate (was: Unconfirmed)