Toggles header visibility on scroll. Demo.
Installation
npm install hiding-header
How to use
HTML:
<body>
<div class="hidingHeader" id="hidingHeader">
<div class="hidingHeader-in">
</div>
</div>
</body>
CSS:
Import dist/style.css
to your CSS. It's few lines of code. You can alternatively copy paste it and adjust things like z-index
to your needs.
JavaScript:
import { hidingHeader } from 'hiding-header'
const container = document.querySelector('#hidingHeader')
hidingHeader(container)
More
import { hidingHeader } from 'hiding-header'
const container = document.querySelector('#hidingHeader')
const instance = hidingHeader(container, {
heightPropertyName = '--hidingHeader-height',
boundsHeightPropertyName = '--hidingHeader-bounds-height',
animationOffsetPropertyName = '--hidingHeader-animation-offset',
snap = true,
onHeightChange = (height: number) => void,
onVisibleHeightChange = (height: number) => void,
onHomeChange: (isHome: boolean) => void,
})
instance.pause()
instance.isPaused()
instance.run()
instance.reveal()
instance.hide()
instance.getHeight()
instance.getVisibleHeight()
instance.isHome()
React component
For more information see hiding-header-react.
Web component
For more information see hiding-header-webcomponent.