fix(mobile): scroll optimization (#8362)
close AF-1421, AF-1418, AF-1423, AF-1358
This commit is contained in:
@@ -25,9 +25,13 @@ export const useThemeColorMeta = (color: string) => {
|
|||||||
const meta = getMeta();
|
const meta = getMeta();
|
||||||
const old = meta.content;
|
const old = meta.content;
|
||||||
meta.content = color;
|
meta.content = color;
|
||||||
|
// also modify document background (for over scroll bounce effect)
|
||||||
|
const oldBg = document.documentElement.style.backgroundColor;
|
||||||
|
document.documentElement.style.backgroundColor = color;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
meta.content = old;
|
meta.content = old;
|
||||||
|
document.documentElement.style.backgroundColor = oldBg;
|
||||||
};
|
};
|
||||||
}, [color]);
|
}, [color]);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -161,7 +161,9 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|||||||
data-disabled={disabled || undefined}
|
data-disabled={disabled || undefined}
|
||||||
data-size={size}
|
data-size={size}
|
||||||
data-variant={variant}
|
data-variant={variant}
|
||||||
data-no-hover={withoutHover || undefined}
|
data-no-hover={
|
||||||
|
withoutHover || BUILD_CONFIG.isMobileEdition || undefined
|
||||||
|
}
|
||||||
data-mobile={BUILD_CONFIG.isMobileEdition}
|
data-mobile={BUILD_CONFIG.isMobileEdition}
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ export function useNavigateHelper() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const openPage = useCallback(
|
const openPage = useCallback(
|
||||||
(workspaceId: string, pageId: string) => {
|
(workspaceId: string, pageId: string, logic?: RouteLogic) => {
|
||||||
return jumpToPage(workspaceId, pageId);
|
return jumpToPage(workspaceId, pageId, logic);
|
||||||
},
|
},
|
||||||
[jumpToPage]
|
[jumpToPage]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import {
|
|||||||
import { type LoaderFunction, useSearchParams } from 'react-router-dom';
|
import { type LoaderFunction, useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { AppFallback } from '../../components/affine/app-container';
|
import { AppFallback } from '../../components/affine/app-container';
|
||||||
import { useNavigateHelper } from '../../components/hooks/use-navigate-helper';
|
import {
|
||||||
|
RouteLogic,
|
||||||
|
useNavigateHelper,
|
||||||
|
} from '../../components/hooks/use-navigate-helper';
|
||||||
import { WorkspaceNavigator } from '../../components/workspace-selector';
|
import { WorkspaceNavigator } from '../../components/workspace-selector';
|
||||||
import { AuthService } from '../../modules/cloud';
|
import { AuthService } from '../../modules/cloud';
|
||||||
import {
|
import {
|
||||||
@@ -102,7 +105,7 @@ export const Component = ({
|
|||||||
const lastId = localStorage.getItem('last_workspace_id');
|
const lastId = localStorage.getItem('last_workspace_id');
|
||||||
|
|
||||||
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
|
const openWorkspace = list.find(w => w.id === lastId) ?? list[0];
|
||||||
openPage(openWorkspace.id, defaultIndexRoute);
|
openPage(openWorkspace.id, defaultIndexRoute, RouteLogic.REPLACE);
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
createCloudWorkspace,
|
createCloudWorkspace,
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
|
|||||||
}, [backAction]);
|
}, [backAction]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<SafeArea
|
<SafeArea
|
||||||
top
|
top
|
||||||
ref={ref}
|
ref={ref}
|
||||||
@@ -88,7 +89,9 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
|
|||||||
{prefix}
|
{prefix}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section className={clsx(styles.content, { center: centerContent })}>
|
<section
|
||||||
|
className={clsx(styles.content, { center: centerContent })}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
@@ -100,6 +103,12 @@ export const PageHeader = forwardRef<HTMLDivElement, PageHeaderProps>(
|
|||||||
</section>
|
</section>
|
||||||
</header>
|
</header>
|
||||||
</SafeArea>
|
</SafeArea>
|
||||||
|
|
||||||
|
{/* Spacer */}
|
||||||
|
<SafeArea top>
|
||||||
|
<div className={styles.headerSpacer} />
|
||||||
|
</SafeArea>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -3,13 +3,16 @@ import { style } from '@vanilla-extract/css';
|
|||||||
|
|
||||||
export const root = style({
|
export const root = style({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
position: 'sticky',
|
position: 'fixed',
|
||||||
top: 0,
|
top: 0,
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
backgroundColor: cssVarV2('layer/background/secondary'),
|
backgroundColor: cssVarV2('layer/background/secondary'),
|
||||||
});
|
});
|
||||||
|
export const headerSpacer = style({
|
||||||
|
height: 44,
|
||||||
|
});
|
||||||
export const inner = style({
|
export const inner = style({
|
||||||
minHeight: 44,
|
height: 44,
|
||||||
padding: '0 6px',
|
padding: '0 6px',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ import { cssVarV2 } from '@toeverything/theme/v2';
|
|||||||
import { style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const root = style({
|
export const root = style({
|
||||||
maxHeight: 'calc(100dvh - 100px)',
|
maxHeight:
|
||||||
|
'calc(100dvh - 100px - env(safe-area-inset-bottom) - env(safe-area-inset-top))',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -116,7 +116,9 @@ export const SelectorMenu = ({ onClose }: { onClose?: () => void }) => {
|
|||||||
title="Cloud Sync"
|
title="Cloud Sync"
|
||||||
list={cloudWorkspaces}
|
list={cloudWorkspaces}
|
||||||
/>
|
/>
|
||||||
|
{cloudWorkspaces.length && localWorkspaces.length ? (
|
||||||
<div className={styles.divider} />
|
<div className={styles.divider} />
|
||||||
|
) : null}
|
||||||
<WorkspaceList
|
<WorkspaceList
|
||||||
onClose={onClose}
|
onClose={onClose}
|
||||||
title="Local Storage"
|
title="Local Storage"
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const root = style({
|
|||||||
|
|
||||||
export const header = style({
|
export const header = style({
|
||||||
background: cssVarV2('layer/background/primary'),
|
background: cssVarV2('layer/background/primary'),
|
||||||
position: 'sticky',
|
position: 'fixed',
|
||||||
top: 0,
|
top: 0,
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ globalStyle(':root', {
|
|||||||
globalStyle('body', {
|
globalStyle('body', {
|
||||||
height: 'auto',
|
height: 'auto',
|
||||||
minHeight: '100dvh',
|
minHeight: '100dvh',
|
||||||
|
overflowY: 'unset',
|
||||||
});
|
});
|
||||||
globalStyle('body:has(#app-tabs)', {
|
globalStyle('body:has(#app-tabs)', {
|
||||||
paddingBottom: globalVars.appTabHeight,
|
paddingBottom: globalVars.appTabHeight,
|
||||||
});
|
});
|
||||||
globalStyle('html', {
|
globalStyle('html', {
|
||||||
|
height: '100dvh',
|
||||||
overflowY: 'auto',
|
overflowY: 'auto',
|
||||||
background: cssVarV2('layer/background/secondary'),
|
background: cssVarV2('layer/background/secondary'),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user