Compensate for visual viewport when moving cursor
This commit is contained in:
parent
bb09e766ba
commit
48f15efa69
|
@ -125,8 +125,16 @@ export default class Cursor {
|
|||
if (!useFallback) {
|
||||
return;
|
||||
}
|
||||
this._position.x = clientX;
|
||||
this._position.y = clientY;
|
||||
// clientX/clientY are relative the _visual viewport_,
|
||||
// but our position is relative the _layout viewport_,
|
||||
// so try to compensate when we can
|
||||
if (window.visualViewport) {
|
||||
this._position.x = clientX + window.visualViewport.offsetLeft;
|
||||
this._position.y = clientY + window.visualViewport.offsetTop;
|
||||
} else {
|
||||
this._position.x = clientX;
|
||||
this._position.y = clientY;
|
||||
}
|
||||
this._updatePosition();
|
||||
let target = document.elementFromPoint(clientX, clientY);
|
||||
this._updateVisibility(target);
|
||||
|
|
Loading…
Reference in New Issue