mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-20 23:16:49 +00:00
微调
This commit is contained in:
@@ -1,11 +1,36 @@
|
||||
import PropTypes from 'prop-types'
|
||||
import React, { useEffect } from 'react'
|
||||
import CommonHead from '@/components/CommonHead'
|
||||
import TopNav from '@/components/TopNav'
|
||||
|
||||
const Container = ({ children, layout, fullWidth, ...customMeta }) => {
|
||||
const Container = ({ children, layout, fullWidth, tags, meta, ...customMeta }) => {
|
||||
let windowTop = 0
|
||||
// 监听滚动
|
||||
useEffect(() => {
|
||||
function scrollTrigger () {
|
||||
const scrollS = window.scrollY
|
||||
const nav = document.querySelector('#sticky-nav')
|
||||
const tagsBar = document.querySelector('#tags-bar')
|
||||
console.log(windowTop, scrollS)
|
||||
if (scrollS >= windowTop) {
|
||||
nav && nav.classList.add('-mt-16')
|
||||
tagsBar && tagsBar.classList.add('-mt-32')
|
||||
windowTop = scrollS
|
||||
} else {
|
||||
nav && nav.classList.remove('-mt-16')
|
||||
tagsBar && tagsBar.classList.remove('-mt-32')
|
||||
windowTop = scrollS
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('scroll', scrollTrigger)
|
||||
})
|
||||
return (
|
||||
<div>
|
||||
{/* 公共头 */}
|
||||
<>
|
||||
<CommonHead meta={meta} />
|
||||
<TopNav tags={tags}/>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user