diff --git a/core/util/cursor.js b/core/util/cursor.js index 3f0b01bd..009bd6de 100644 --- a/core/util/cursor.js +++ b/core/util/cursor.js @@ -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);