Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/settings/disable motion: refactor
Adorian Doran3e3cc8c54115
diff --git a/apps/client/src/widgets/containers/root_container.ts b/apps/client/src/widgets/containers/root_container.tsindex c941cdd88c..ef2491b649 100644--- a/apps/client/src/widgets/containers/root_container.ts+++ b/apps/client/src/widgets/containers/root_container.ts@@ -1,6 +1,8 @@-import utils from "../../services/utils.js";-import type BasicWidget from "../basic_widget.js";+import { EventData } from "../../components/app_context.js";import FlexContainer from "./flex_container.js";+import options from "../../services/options.js";+import type BasicWidget from "../basic_widget.js";+import utils from "../../services/utils.js";/*** The root container is the top-most widget/container, from which the entire layout derives.@@ -20,6 +22,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {this.id("root-widget");this.css("height", "100dvh");this.originalViewportHeight = getViewportHeight();+}render(): JQuery<HTMLElement> {@@ -27,15 +30,27 @@ export default class RootContainer extends FlexContainer<BasicWidget> {window.visualViewport?.addEventListener("resize", () => this.#onMobileResize());}+ this.#setMotion(options.is("motionEnabled"));+return super.render();}+ entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {+ if (loadResults.isOptionReloaded("motionEnabled")) {+ this.#setMotion(options.is("motionEnabled"));+ }+ }+#onMobileResize() {const currentViewportHeight = getViewportHeight();const isKeyboardOpened = (currentViewportHeight < this.originalViewportHeight);this.$widget.toggleClass("virtual-keyboard-opened", isKeyboardOpened);}+ #setMotion(enabled: boolean) {+ document.body.classList.toggle("motion-disabled", !enabled);+ jQuery.fx.off = !enabled;+ }}function getViewportHeight() {diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsxindex b54c8acc8d..de22a9b1b8 100644--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx@@ -247,7 +247,7 @@ function ElectronIntegration() {}function Performance() {- const [ motionEnabled, setMotionEnabled ] = useTriliumOptionBool("motionEnabled", true);+ const [ motionEnabled, setMotionEnabled ] = useTriliumOptionBool("motionEnabled");return <OptionsSection title={t("ui-performance.title")}><FormGroup name="motion-enabled">diff --git a/apps/server/src/assets/views/desktop.ejs b/apps/server/src/assets/views/desktop.ejsindex 1158612beb..374ed0b8cc 100644--- a/apps/server/src/assets/views/desktop.ejs+++ b/apps/server/src/assets/views/desktop.ejs@@ -9,7 +9,7 @@<link rel="manifest" crossorigin="use-credentials" href="manifest.webmanifest"><title>Trilium Notes</title></head>-<body id="trilium-app" class="desktop heading-style-<%= headingStyle %> layout-<%= layoutOrientation %> platform-<%= platform %> <%= isElectron ? 'electron' : '' %> <%= hasNativeTitleBar ? 'native-titlebar' : '' %> <%= hasBackgroundEffects ? 'background-effects' : '' %> <%= motionEnabled ? '' : 'motion-disabled' %>">+<body id="trilium-app" class="desktop heading-style-<%= headingStyle %> layout-<%= layoutOrientation %> platform-<%= platform %> <%= isElectron ? 'electron' : '' %> <%= hasNativeTitleBar ? 'native-titlebar' : '' %> <%= hasBackgroundEffects ? 'background-effects' : '' %>"><noscript><%= t("javascript-required") %></noscript><script>@@ -56,12 +56,5 @@<script src="<%= appPath %>/runtime.js" crossorigin type="module"></script><script src="<%= appPath %>/desktop.js" crossorigin type="module"></script>-<script>- // Turn off jQuery animations if motion is disabled- addEventListener("DOMContentLoaded", () => {- jQuery.fx.off = <%= motionEnabled !== true %>;- });-</script>-</body></html>diff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.tsindex 9fb682c14a..79a40f1864 100644--- a/apps/server/src/routes/index.ts+++ b/apps/server/src/routes/index.ts@@ -53,7 +53,6 @@ function index(req: Request, res: Response) {isDev,isMainWindow: view === "mobile" ? true : !req.query.extraWindow,isProtectedSessionAvailable: protectedSessionService.isProtectedSessionAvailable(),- motionEnabled: options.motionEnabled === "true",maxContentWidth: Math.max(640, parseInt(options.maxContentWidth)),triliumVersion: packageJson.version,assetPath: assetPath,