Skip to content

Commit

Permalink
docs: optimize the experience issues with the top navigation changes …
Browse files Browse the repository at this point in the history
…during scrolling

 - fix: #203
  • Loading branch information
YumoImer committed Nov 27, 2024
1 parent 656f5af commit a78275d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions .dumi/theme/slots/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const useStyle = createStyles(({ token, css }) => {
display: flex;
align-items: center;
justify-content: space-between;
transition: padding 0.2s ease-in-out, margin 0.2s ease-in-out, opacity 0.2s ease-in-out;
`,
mobile: css`
height: 48px;
Expand All @@ -49,6 +50,9 @@ const useStyle = createStyles(({ token, css }) => {
inset-inline-end: 50%;
transform: translateX(50%);
`,
hidden: css`
opacity: 0;
`,
mini_rtl: css`
inset-inline-start: 50%;
`,
Expand Down Expand Up @@ -105,7 +109,7 @@ const Header: React.FC = () => {

const { scrollY, scrollYDirection } = useScrollY();

const isMini = scrollY > 800 && !isMobile;
const isMini = scrollY > window.innerHeight && !isMobile;

const sharedProps: SharedProps = {
isZhCN: lang === 'cn',
Expand Down Expand Up @@ -146,6 +150,8 @@ const Header: React.FC = () => {
);
}

const isHidden = scrollY > window.innerHeight * 1.5 && scrollYDirection === 'down';

return (
<header
className={classnames(
Expand All @@ -154,10 +160,8 @@ const Header: React.FC = () => {
(isMobile || isMini) && styles.mobile,
isMini && styles.mini,
isMini && direction === 'rtl' && styles.mini_rtl,
isHidden && styles.hidden,
)}
style={{
display: scrollY > 900 && scrollYDirection === 'down' ? 'none' : 'flex',
}}
>
<Logo {...sharedProps} />
{isMobile && (
Expand Down

0 comments on commit a78275d

Please sign in to comment.