client: allow changing the max content width option without a frontend reload

This commit is contained in:
Adorian Doran
2025-10-30 00:49:02 +02:00
parent 1ef03b7a77
commit 4063229982
3 changed files with 11 additions and 5 deletions

View File

@@ -31,6 +31,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
window.visualViewport?.addEventListener("resize", () => this.#onMobileResize());
}
this.#setMaxContentWidth(options.getInt("maxContentWidth") ?? 0);
this.#setMotion(options.is("motionEnabled"));
this.#setShadows(options.is("shadowsEnabled"));
this.#setBackdropEffects(options.is("backdropEffectsEnabled"));
@@ -52,14 +53,24 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
if (loadResults.isOptionReloaded("backdropEffectsEnabled")) {
this.#setBackdropEffects(options.is("backdropEffectsEnabled"));
}
if (loadResults.isOptionReloaded("maxContentWidth")) {
this.#setMaxContentWidth(options.getInt("maxContentWidth") ?? 0);
}
}
#onMobileResize() {
const currentViewportHeight = getViewportHeight();
const isKeyboardOpened = (currentViewportHeight < this.originalViewportHeight);
this.$widget.toggleClass("virtual-keyboard-opened", isKeyboardOpened);
}
#setMaxContentWidth(width: number) {
width = Math.max(width, 640);
document.body.style.setProperty("--preferred-max-content-width", `${width}px`);
}
#setMotion(enabled: boolean) {
document.body.classList.toggle("motion-disabled", !enabled);
jQuery.fx.off = !enabled;