mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-23 07:26:47 +00:00
Hexo导航栏微调
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { useGlobal } from '@/lib/global'
|
||||
import { useEffect, useState } from 'react'
|
||||
import Typed from 'typed.js'
|
||||
import CONFIG_HEXO from '../config_hexo'
|
||||
@@ -13,12 +12,10 @@ let autoScroll = false
|
||||
*/
|
||||
const Header = props => {
|
||||
const [typed, changeType] = useState()
|
||||
const { isDarkMode } = useGlobal()
|
||||
const { siteInfo } = props
|
||||
useEffect(() => {
|
||||
scrollTrigger()
|
||||
updateHeaderHeight()
|
||||
updateTopNav()
|
||||
if (!typed && window && document.getElementById('typed')) {
|
||||
changeType(
|
||||
new Typed('#typed', {
|
||||
@@ -48,17 +45,6 @@ const Header = props => {
|
||||
|
||||
const scrollTrigger = () => {
|
||||
const scrollS = window.scrollY
|
||||
const nav = document.querySelector('#sticky-nav')
|
||||
|
||||
if (scrollS < 500) {
|
||||
nav && nav.classList.replace('bg-white', 'bg-none')
|
||||
nav && nav.classList.replace('text-black', 'text-white')
|
||||
nav && nav.classList.replace('border', 'border-transparent')
|
||||
} else {
|
||||
nav && nav.classList.replace('bg-none', 'bg-white')
|
||||
nav && nav.classList.replace('text-white', 'text-black')
|
||||
nav && nav.classList.replace('border-transparent', 'border')
|
||||
}
|
||||
|
||||
// 自动滚动
|
||||
if ((scrollS > windowTop) & (scrollS < window.innerHeight) && !autoScroll
|
||||
@@ -73,19 +59,6 @@ const Header = props => {
|
||||
setTimeout(autoScrollEnd, 500)
|
||||
}
|
||||
windowTop = scrollS
|
||||
|
||||
updateTopNav()
|
||||
}
|
||||
|
||||
const updateTopNav = () => {
|
||||
if (!isDarkMode) {
|
||||
const stickyNavElement = document.getElementById('sticky-nav')
|
||||
if (window.scrollY < window.innerHeight) {
|
||||
stickyNavElement?.classList?.add('dark')
|
||||
} else {
|
||||
stickyNavElement?.classList?.remove('dark')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateHeaderHeight () {
|
||||
|
||||
Reference in New Issue
Block a user