Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Keep the background unchanged during mobile sidebar swipes https://github.com/siyuan-note/siyuan/issues/14542

Danielfb4cafbf258a
diff --git a/app/src/mobile/util/touch.ts b/app/src/mobile/util/touch.ts
index 46a9ab37bb..5adfdb6f7b 100644
--- a/app/src/mobile/util/touch.ts
+++ b/app/src/mobile/util/touch.ts
@@ -23,7 +23,6 @@ import {
getOpeningSidebar,
getOpenSidebarReleaseAction,
getSidebarClosingOffset,
- getSidebarMaskOpacity,
getSidebarOpeningOffset,
type MobileSidebarSide,
type MobileSwipeDirection,
@@ -572,6 +571,7 @@ export const handleTouchMove = (event: TouchEvent) => {
return;
}
sideMaskElement.style.zIndex = (++window.siyuan.zIndex).toString();
+ showPanelMask();
const activeSidebar = getTargetSidebar(target) || openingSidebar;
updateSidebarSwipeState(activeSidebar);
getSidebarElement(activeSidebar).style.zIndex = (++window.siyuan.zIndex).toString();
@@ -582,7 +582,6 @@ export const handleTouchMove = (event: TouchEvent) => {
if (targetSidebar) {
const offset = getSidebarClosingOffset(targetSidebar, xDiff, windowWidth);
getSidebarElement(targetSidebar).style.transform = `translateX(${offset}px)`;
- transformMask(Math.abs(offset) / windowWidth);
return;
}
@@ -591,15 +590,9 @@ export const handleTouchMove = (event: TouchEvent) => {
getSidebarElement(otherSidebar)?.style.removeProperty("transform");
const offset = getSidebarOpeningOffset(openingSidebar, xDiff, windowWidth);
getSidebarElement(openingSidebar).style.transform = `translateX(${offset}px)`;
- transformMask(Math.abs(offset) / windowWidth);
activeBlur();
if (window.siyuan.mobile.editor) {
window.siyuan.mobile.editor.protyle.contentElement.style.overflow = "hidden";
}
}
};
-
-const transformMask = (closedRatio: number) => {
- const maskElement = showPanelMask();
- maskElement.style.opacity = getSidebarMaskOpacity(closedRatio).toString();
-};
diff --git a/app/src/mobile/util/touchPanelGesture.test.ts b/app/src/mobile/util/touchPanelGesture.test.ts
index 0df1ebb10a..887228dc28 100644
--- a/app/src/mobile/util/touchPanelGesture.test.ts
+++ b/app/src/mobile/util/touchPanelGesture.test.ts
@@ -5,9 +5,7 @@ import {
getOpenSidebarReleaseAction,
getSidebarClosingDirection,
getSidebarClosingOffset,
- getSidebarMaskOpacity,
getSidebarOpeningOffset,
- MOBILE_SIDEBAR_MASK_MAX_OPACITY,
MOBILE_SIDEBAR_MASK_SWIPING_CLASS,
MOBILE_SIDEBAR_SWIPING_CLASS,
setSidebarSwipeState,
@@ -78,14 +76,6 @@ describe("mobile sidebar touch gesture", () => {
assert.equal(getSidebarOpeningOffset("right", 400, 300), 0);
});
- it("dims the page gently in proportion to the open sidebar", () => {
- assert.equal(getSidebarMaskOpacity(1), 0);
- assert.equal(getSidebarMaskOpacity(0.5), MOBILE_SIDEBAR_MASK_MAX_OPACITY / 2);
- assert.equal(getSidebarMaskOpacity(0), MOBILE_SIDEBAR_MASK_MAX_OPACITY);
- assert.equal(getSidebarMaskOpacity(-1), MOBILE_SIDEBAR_MASK_MAX_OPACITY);
- assert.equal(getSidebarMaskOpacity(2), 0);
- });
-
it("keeps only the active sidebar in the swiping state", () => {
const left = createClassTarget();
const right = createClassTarget();
diff --git a/app/src/mobile/util/touchPanelGesture.ts b/app/src/mobile/util/touchPanelGesture.ts
index eb8cc5812e..eee91ae028 100644
--- a/app/src/mobile/util/touchPanelGesture.ts
+++ b/app/src/mobile/util/touchPanelGesture.ts
@@ -4,7 +4,6 @@ export type MobileSidebarReleaseAction = "close" | "open";
export const MOBILE_SIDEBAR_SWIPING_CLASS = "side-panel--swiping";
export const MOBILE_SIDEBAR_MASK_SWIPING_CLASS = "side-mask--swiping";
-export const MOBILE_SIDEBAR_MASK_MAX_OPACITY = 0.32;
interface IMobileSidebarSwipeClassTarget {
classList: {
@@ -66,8 +65,3 @@ export const getSidebarOpeningOffset = (side: MobileSidebarSide, xDiff: number,
}
return Math.max(Math.min(width - xDiff, width), 0);
};
-
-export const getSidebarMaskOpacity = (closedRatio: number) => {
- const openRatio = 1 - Math.min(Math.max(closedRatio, 0), 1);
- return openRatio * MOBILE_SIDEBAR_MASK_MAX_OPACITY;
-};