Skip to content

Commit

Permalink
feat: add scroll.hide_header configuration item
Browse files Browse the repository at this point in the history
  • Loading branch information
XPoet committed Nov 3, 2023
1 parent 83711e9 commit 1bc6ba1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,20 @@ scroll:
# Show percent when page scroll
percent: false # Option values: true | false

# Hide header in top when page scroll
hide_header: true # Option values: true | false


# ---------------------------------------------------------------------------------------
# Docs: https://keep-docs.xpoet.cn/basis/configuration-guide/home.html
# ---------------------------------------------------------------------------------------
home:
# Show category in home page article block
category: false # Option values: true | false

# Show tags in home page article block
tag: false # Option values: true | false

# Website announcement in home page
announcement:

Expand Down
10 changes: 8 additions & 2 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ KEEP.initUtils = () => {
isHasScrollProgressBar: false,
isHasScrollPercent: false,
isHeaderTransparent: false,
isHideHeader: true,
hasToc: false,

// initialization data
Expand All @@ -30,6 +31,7 @@ KEEP.initUtils = () => {
if (!this.isHeaderTransparent) {
this.headerWrapperDom.classList.remove('transparent-1', 'transparent-2')
}
this.isHideHeader = scroll?.hide_header !== false
},

// scroll Style Handle
Expand Down Expand Up @@ -73,12 +75,16 @@ KEEP.initUtils = () => {

// hide header handle
if (scrollTop > this.prevScrollValue && scrollTop > this.innerHeight) {
this.pageTopDom.classList.add('hide')
if (this.isHideHeader) {
this.pageTopDom.classList.add('hide')
}
if (this.isHeaderTransparent) {
this.headerWrapperDom.classList.remove('transparent-1', 'transparent-2')
}
} else {
this.pageTopDom.classList.remove('hide')
if (this.isHideHeader) {
this.pageTopDom.classList.remove('hide')
}
if (this.isHeaderTransparent) {
if (scrollTop <= this.headerWrapperDom.getBoundingClientRect().height) {
this.headerWrapperDom.classList.remove('transparent-2')
Expand Down

0 comments on commit 1bc6ba1

Please sign in to comment.