Skip to content

Commit

Permalink
fix scroll trigger hysteresis
Browse files Browse the repository at this point in the history
  • Loading branch information
ibastawisi committed Jan 13, 2025
1 parent e9b35a4 commit e40a48d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/components/Layout/TopAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,15 @@ import { Print, KeyboardArrowUp, Info } from '@mui/icons-material';
function HideOnScroll({ children }: { children: React.ReactElement }) {
const pathname = usePathname();
const shouldHide = !!['/edit', '/playground', '/tutorial'].find(path => pathname.startsWith(path));
const trigger = useScrollTrigger({
disableHysteresis: false,
threshold: 32,
});
const trigger = useScrollTrigger({ threshold: 32 });
if (!shouldHide) return children;
return (
<Slide appear={false} direction="down" in={!trigger}>{children}</Slide>
);
}

function ScrollTop() {
const trigger = useScrollTrigger({
disableHysteresis: false,
});
const trigger = useScrollTrigger({ disableHysteresis: true });

const handleClick = () => {
const anchor = document.querySelector('#back-to-top-anchor');
Expand Down
6 changes: 1 addition & 5 deletions src/components/ViewDocumentInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import ViewRevisionCard from './ViewRevisionCard';
import { useSearchParams } from 'next/navigation';

export default function EditDocumentInfo({ cloudDocument, user }: { cloudDocument: CloudDocument, user?: User }) {
const slideTrigger = useScrollTrigger({
disableHysteresis: true,
threshold: 100,
});

const slideTrigger = useScrollTrigger({ disableHysteresis: true });
const handle = cloudDocument.handle || cloudDocument.id;
const isAuthor = cloudDocument.author.id === user?.id;
const isCoauthor = cloudDocument.coauthors.some(u => u.id === user?.id);
Expand Down

0 comments on commit e40a48d

Please sign in to comment.