An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: Prevent mobile database header jumps and transparent gaps https://github.com/siyuan-note/siyuan/issues/19596
Danielab9d766e7fa8
diff --git a/app/src/assets/scss/main/_mobile.scss b/app/src/assets/scss/main/_mobile.scssindex aa269287f2..4c8722560f 100644--- a/app/src/assets/scss/main/_mobile.scss+++ b/app/src/assets/scss/main/_mobile.scss@@ -612,9 +612,8 @@ body.mobile-topbar--merged {z-index: 5;height: var(--mobile-breadcrumb-height);border-radius: 0;- opacity: var(--mobile-bar-opacity, 1);transform: translate3d(0, var(--mobile-bar-translate-y, 0), 0);- will-change: opacity, transform;+ will-change: transform;}> .protyle-content {diff --git a/app/src/mobile/util/mobileBars.test.ts b/app/src/mobile/util/mobileBars.test.tsindex 79fd2862b3..790b5f3c19 100644--- a/app/src/mobile/util/mobileBars.test.ts+++ b/app/src/mobile/util/mobileBars.test.ts@@ -73,12 +73,14 @@ describe("mobile bars", () => {},});const breadcrumbElement = new TestBreadcrumbElement();+ const topbarElement = new TestBreadcrumbElement();const scrollElement = new TestScrollElement();Object.defineProperty(globalThis, "document", {configurable: true,value: {body: {classList: new TestClassList()},- getElementById: (): undefined => undefined,+ getElementById: (id: string): TestBreadcrumbElement | undefined =>+ id === "mobileTopBar" ? topbarElement : undefined,querySelector: (): TestBreadcrumbElement => breadcrumbElement,},});@@ -97,8 +99,13 @@ describe("mobile bars", () => {notified++;});assert.equal(notified, 1);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-translate-y"), "0px");- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "1");+ const assertPosition = (progress: number) => {+ const translation = `calc(${0 - progress} * (var(--mobile-topbar-height) + var(--mobile-breadcrumb-height)))`;+ assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-translate-y"), translation);+ assert.equal(topbarElement.style.getPropertyValue("--mobile-bar-translate-y"), translation);+ assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "");+ };+ assertPosition(0);assert.equal(breadcrumbElement.attributes.has("inert"), false);assert.equal(breadcrumbElement.attributes.get("aria-hidden"), "false");const scrollTo = (top: number) => {@@ -107,21 +114,26 @@ describe("mobile bars", () => {frame(0);};scrollTo(24);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "0.5");+ assertPosition(0.5);+ scrollTo(47);+ assertPosition(47 / 48);scrollTo(48);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "0");+ assertPosition(1);assert.equal(breadcrumbElement.attributes.has("inert"), true);assert.equal(breadcrumbElement.attributes.get("aria-hidden"), "true");+ scrollTo(47);+ assertPosition(47 / 48);+ assert.equal(breadcrumbElement.attributes.get("aria-hidden"), "false");scrollTo(0);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "1");+ assertPosition(0);assert.equal(breadcrumbElement.attributes.has("inert"), false);storage[MOBILE_BARS_CONFIG_KEY].autoHide = false;scrollTo(100);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "1");+ assertPosition(0);assert.equal(breadcrumbElement.attributes.get("aria-hidden"), "false");storage[MOBILE_BARS_CONFIG_KEY].autoHide = true;scrollTo(148);- assert.equal(breadcrumbElement.style.getPropertyValue("--mobile-bar-opacity"), "0");+ assertPosition(1);} finally {clearMobileBarsScroll();Object.defineProperty(globalThis, "document", {configurable: true, value: originalDocument});diff --git a/app/src/mobile/util/mobileBars.ts b/app/src/mobile/util/mobileBars.tsindex c8902b2629..b1f65d98fb 100644--- a/app/src/mobile/util/mobileBars.ts+++ b/app/src/mobile/util/mobileBars.ts@@ -44,18 +44,18 @@ const renderMobileBars = () => {const progress = MOBILE_BARS_SCROLL_OPTIONS.maxOffset === 0 ? 0 :barsState.readingBarsOffset / MOBILE_BARS_SCROLL_OPTIONS.maxOffset;+ // 顶栏和面包屑整体滑出,使完全隐藏时的底边与滚动视口顶部重合。+ const breadcrumbTranslateY = `calc(${0 - progress} * (var(--mobile-topbar-height) + var(--mobile-breadcrumb-height)))`;const topbarElement = document.getElementById("mobileTopBar");if (topbarElement) {- topbarElement.style.setProperty("--mobile-bar-translate-y", `${0 - barsState.readingBarsOffset}px`);+ topbarElement.style.setProperty("--mobile-bar-translate-y", breadcrumbTranslateY);topbarElement.toggleAttribute("inert", immersive);topbarElement.setAttribute("aria-hidden", immersive ? "true" : "false");}const breadcrumbElement = document.querySelector<HTMLElement>("#editor > .protyle-breadcrumb");- const breadcrumbTranslateY = `${0 - barsState.readingBarsOffset}px`;const breadcrumbPositionChanged = breadcrumbElement &&breadcrumbElement.style.getPropertyValue("--mobile-bar-translate-y") !== breadcrumbTranslateY;breadcrumbElement?.style.setProperty("--mobile-bar-translate-y", breadcrumbTranslateY);- breadcrumbElement?.style.setProperty("--mobile-bar-opacity", (1 - progress).toString());breadcrumbElement?.toggleAttribute("inert", immersive);breadcrumbElement?.setAttribute("aria-hidden", immersive ? "true" : "false");if (breadcrumbPositionChanged) {diff --git a/app/src/protyle/render/av/backlinkSticky.test.ts b/app/src/protyle/render/av/backlinkSticky.test.tsindex 46deaefcfd..9ac75775bc 100644--- a/app/src/protyle/render/av/backlinkSticky.test.ts+++ b/app/src/protyle/render/av/backlinkSticky.test.ts@@ -38,13 +38,14 @@ test("sticky views follow visible breadcrumbs and return to the viewport top whegetBoundingClientRect: () => ({bottom: 600}),};let hidden = false;+ let breadcrumbBottom = 72;const scroll = {scrollTop: 200,getBoundingClientRect: () => ({top: 24, bottom: 800}),previousElementSibling: {classList: {contains: (name: string) => name === "protyle-breadcrumb"},getAttribute: () => hidden ? "true" : null,- getBoundingClientRect: () => ({bottom: 72}),+ getBoundingClientRect: () => ({bottom: breadcrumbBottom}),},};exports.stickyRow(block, scroll, "top");@@ -65,6 +66,20 @@ test("sticky views follow visible breadcrumbs and return to the viewport top whehidden = false;exports.stickyRow(block, scroll, "top");assert.equal(views.style.top, "72px");+ for (const topbarHeight of [48, 0]) {+ let previousTop: number | undefined;+ for (const offset of [46, 47, 48, 47, 46]) {+ hidden = offset === 48;+ breadcrumbBottom = 24 + (topbarHeight + 42) * (1 - offset / 48);+ exports.stickyRow(block, scroll, "top");+ const top = parseFloat(views.style.top);+ assert.equal(top, Math.round(breadcrumbBottom));+ if (previousTop !== undefined) {+ assert.ok(Math.abs(top - previousTop) <= 2);+ }+ previousTop = top;+ }+ }});test("backlink scrolling clears fixed rows and their spacers without calculating window positions", () => {