0.3.0 • Published 2 years ago

vue-detachable-header v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

vue-detachable-header

Wrap your header in this to get it to reveal itself in a detached state on scroll up. Elegantly handles the transition back to a docked state on scroll back to top.

Usage

import Vue from 'vue'
import DetachableHeader from 'vue-detachable-header'
import 'vue-detachable-header/index.css'
Vue.component('detachable-header', DetachableHeader)
<detachable-header :height="80">
  <desktop-header>...</desktop-header>
</detachable-header>
.desktop-header {

  /* Fill the height of the detachable-header */
  height: 100%;

  /* Make the header text white at the top of the page */
  color: white;
  background: transparent;
}

/* Switch to inverterd styling when detached */
.show-background .desktop-header {
  color: black;
  background: white;
}

Props

NameDefaultDescription
heightundefinedThe height of the header as an integer.
offset0Adjusts the top of the header by this amount when at the top of the page. Useful when the site has a notification bar above the header; you would set this value to the height of the notification bar.
no-offset-when-detachedfalseWhen false, if there is an offset, the header respects the offset when detached (aka, when you have scrolled down the page a ways and then scrolled back up). This is useful for notification bars that don't hide on scrol. When true, the header has a top of 0 when it's detached.
reveal-transition"translate"How the header enters when detached. Supports "translate" and "fade".
force-backgroundfalseForces show-background class.
force-revealfalseForces reveal of detached state.
scrollundefinedManually pass in the current scroll value. This could be useful when used with a smooth scrolling library.
0.3.0

2 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago