Skip to content

Commit dc17c1e

Browse files
committed
zoom-medium fix
1 parent 2f42c21 commit dc17c1e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

components/NotionPage.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -84,35 +84,35 @@ const NotionPage = ({ post, className }) => {
8484
}, [])
8585

8686
const zoom =
87-
typeof window !== 'undefined' &&
87+
isBrowser &&
8888
mediumZoom({
89-
container: '.notion-viewport',
89+
// container: '.notion-viewport',
9090
background: 'rgba(0, 0, 0, 0.2)',
9191
margin: getMediumZoomMargin()
9292
})
93+
9394
const zoomRef = useRef(zoom ? zoom.clone() : null)
9495

9596
useEffect(() => {
96-
if (!isBrowser) return
97-
9897
// 将相册gallery下的图片加入放大功能
9998
if (siteConfig('POST_DISABLE_GALLERY_CLICK')) {
10099
setTimeout(() => {
101-
const imgList = document?.querySelectorAll(
102-
'.notion-asset-wrapper-image img'
103-
)
104-
105-
console.log('放大', imgList)
106-
107-
if (imgList && zoomRef.current) {
108-
for (let i = 0; i < imgList.length; i++) {
109-
zoomRef.current.attach(imgList[i])
100+
if (isBrowser) {
101+
const imgList = document?.querySelectorAll(
102+
'.notion-collection-card-cover img'
103+
)
104+
if (imgList && zoomRef.current) {
105+
for (let i = 0; i < imgList.length; i++) {
106+
zoomRef.current.attach(imgList[i])
107+
}
110108
}
111-
}
112109

113-
const cards = document.getElementsByClassName('notion-collection-card')
114-
for (const e of cards) {
115-
e.removeAttribute('href')
110+
const cards = document.getElementsByClassName(
111+
'notion-collection-card'
112+
)
113+
for (const e of cards) {
114+
e.removeAttribute('href')
115+
}
116116
}
117117
}, 800)
118118
}

0 commit comments

Comments
 (0)