Skip to content

Commit

Permalink
fix: fix the position of mdx scroll to bottom button on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
jeangovil committed Jul 18, 2023
1 parent 725835d commit 975f769
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ArrowDownIcon, IconButton } from '@acid-info/lsd-react'
import clsx from 'clsx'
import React, { HTMLProps } from 'react'
import { useWindowSize } from 'react-use'
import { makeStyle } from '../../../lib/makeStyle'
import { useHydrated } from '../../../lib/useHydrated'
import { useIsMobile } from '../../../lib/useIsMobile'
import { useScrollY } from '../../../lib/useScrollY'
Expand All @@ -11,10 +13,11 @@ type TProps = {}
export const ScrollToBottom = (
props: TProps & HTMLProps<HTMLButtonElement>,
): JSX.Element => {
const { children, className, ...rest } = props
const { children, className, style, ...rest } = props
const isHydrated = useHydrated()
const scrollY = useScrollY()
const isMobile = useIsMobile()
const ws = useWindowSize()

const handleScrollToBottom = () => {
const article = document.querySelector('.main-wrapper article')
Expand Down Expand Up @@ -42,6 +45,7 @@ export const ScrollToBottom = (
className,
(scrollY > 20 || !isHydrated) && styles.hide,
)}
style={makeStyle({ ...(style ?? {}) }, { vh: ws.height / 100 + 'px' })}
{...(rest as any)}
>
<ArrowDownIcon color="primary" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
position: absolute;
background: rgb(var(--lsd-surface-primary)) !important;
transition: all 0.2s ease-in-out;
transform: translateY(0);
transform: translateY(-2rem);
opacity: 1;

&.hide {
opacity: 0;
transform: translateY(-10px);
transform: translateY(calc(-100% - 2.625rem));
}

bottom: 2rem;
top: calc(100 * var(--vh) - var(--ifm-navbar-height));
transform: translateY(calc(-100% - 2rem));
}

0 comments on commit 975f769

Please sign in to comment.