feat: disable medium-zoom for mobile layout
This commit is contained in:
parent
4e005d56c0
commit
a6519df1a2
|
|
@ -19,7 +19,6 @@ import { Tooltip } from "../ui/Tooltip"
|
|||
import { Trans, useTranslation } from "next-i18next"
|
||||
import { readFiles } from "~/lib/read-files"
|
||||
import { PagesManagerMenu } from "./PagesManagerMenu"
|
||||
import { useMobileLayout } from "~/hooks/useMobileLayout"
|
||||
|
||||
export const PagesManager: React.FC<{
|
||||
isPost: boolean
|
||||
|
|
@ -38,8 +37,6 @@ export const PagesManager: React.FC<{
|
|||
const { t } = useTranslation(["dashboard", "site"])
|
||||
const date = useDate()
|
||||
|
||||
const isMobileLayout = useMobileLayout()
|
||||
|
||||
const pages = useGetPagesBySite({
|
||||
type: isPost ? "post" : "page",
|
||||
site: subdomain!,
|
||||
|
|
|
|||
|
|
@ -46,23 +46,26 @@ export const Image: React.FC<TImageProps> = ({
|
|||
useEffect(() => {
|
||||
const $image = imageRefInternal.current
|
||||
if (!$image) return
|
||||
if (isMobileLayout) {
|
||||
const clickHandler = () => {
|
||||
window.open(getSrc(), "_blank")
|
||||
}
|
||||
$image.addEventListener("click", clickHandler)
|
||||
return () => {
|
||||
$image.removeEventListener("click", clickHandler)
|
||||
}
|
||||
}
|
||||
if (zoom) {
|
||||
import("medium-zoom").then(({ default: mediumZoom }) => {
|
||||
mediumZoom($image, {
|
||||
margin: 10,
|
||||
background: "rgb(var(--tw-colors-i-white))",
|
||||
scrollOffset: 0,
|
||||
})
|
||||
})
|
||||
if (isMobileLayout !== undefined) {
|
||||
if (isMobileLayout) {
|
||||
const clickHandler = () => {
|
||||
window.open(getSrc(), "_blank")
|
||||
}
|
||||
$image.addEventListener("click", clickHandler)
|
||||
return () => {
|
||||
$image.removeEventListener("click", clickHandler)
|
||||
}
|
||||
} else {
|
||||
import("medium-zoom").then(({ default: mediumZoom }) => {
|
||||
mediumZoom($image, {
|
||||
margin: 10,
|
||||
background: "rgb(var(--tw-colors-i-white))",
|
||||
scrollOffset: 0,
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [zoom, isMobileLayout])
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from "react"
|
|||
const mobileWidth = 1024
|
||||
|
||||
export function useMobileLayout() {
|
||||
const [isMobile, setIsMobile] = useState(false)
|
||||
const [isMobile, setIsMobile] = useState<boolean>()
|
||||
|
||||
const onResize = useCallback(() => {
|
||||
setIsMobile(window.innerWidth < mobileWidth)
|
||||
|
|
|
|||
Loading…
Reference in New Issue