feat: disable medium-zoom for mobile layout

This commit is contained in:
DIYgod
2023-04-17 01:07:28 +01:00
parent 4e005d56c0
commit a6519df1a2
3 changed files with 20 additions and 20 deletions
+19 -16
View File
@@ -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])