mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 21:57:36 +08:00
FIX: Prevent content layout shift on mobile (#26238)
This commit is contained in:
parent
4f24e3b3b2
commit
0bf87c5ed8
|
@ -206,15 +206,18 @@ export default MountWidget.extend({
|
||||||
return element.offsetTop + getOffsetTop(element.offsetParent);
|
return element.offsetTop + getOffsetTop(element.offsetParent);
|
||||||
};
|
};
|
||||||
|
|
||||||
const top = getOffsetTop(refreshedElem) - offsetCalculator();
|
window.scrollTo({
|
||||||
window.scrollTo({ top });
|
top: getOffsetTop(refreshedElem) - offsetCalculator(),
|
||||||
|
});
|
||||||
|
|
||||||
// This seems weird, but somewhat infrequently a rerender
|
// This seems weird, but somewhat infrequently a rerender
|
||||||
// will cause the browser to scroll to the top of the document
|
// will cause the browser to scroll to the top of the document
|
||||||
// in Chrome. This makes sure the scroll works correctly if that
|
// in Chrome. This makes sure the scroll works correctly if that
|
||||||
// happens.
|
// happens.
|
||||||
schedule("afterRender", () => {
|
schedule("afterRender", () => {
|
||||||
window.scrollTo({ top });
|
window.scrollTo({
|
||||||
|
top: getOffsetTop(refreshedElem) - offsetCalculator(),
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user