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) {
|
if (!useFallback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._position.x = clientX;
|
// clientX/clientY are relative the _visual viewport_,
|
||||||
this._position.y = clientY;
|
// 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();
|
this._updatePosition();
|
||||||
let target = document.elementFromPoint(clientX, clientY);
|
let target = document.elementFromPoint(clientX, clientY);
|
||||||
this._updateVisibility(target);
|
this._updateVisibility(target);
|
||||||
|
|
Loading…
Reference in New Issue