FIX: weird slow auto scrolling on iOS (#29598)

In some cases, on Safari iOS, we would recompute the "--composer-vh" variable due to a minimal change in the viewport. This ends up triggering a loop where setting this variable triggers another viewport resize event, which triggers another change of the variable...

In order to fix (patch?) this issue, we now have a 1px leeway when checking the difference between the previous and new viewport.

Internal ref - t/141088
This commit is contained in:
Régis Hanol 2024-11-05 17:58:00 +01:00 committed by GitHub
parent 8a201c1e92
commit afdca41fd5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,13 +75,16 @@ export default class DVirtualHeight extends Component {
height = activeWindow?.height || window.innerHeight;
}
const newVh = height * 0.01;
if (this.lastVh === newVh) {
if (this.previousHeight && Math.abs(this.previousHeight - height) <= 1) {
return;
}
document.documentElement.style.setProperty("--composer-vh", `${newVh}px`);
this.lastVh = newVh;
this.previousHeight = height;
document.documentElement.style.setProperty(
"--composer-vh",
`${height / 100}px`
);
}
@bind