mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
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:
parent
8a201c1e92
commit
afdca41fd5
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user