All Projects → digitalfabrik → react-sticky-headroom

digitalfabrik / react-sticky-headroom

Licence: MIT license
A React Component to hide a Header using CSS sticky position

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-sticky-headroom

Floatthead
Fixed <thead>. Doesn't need any custom css/html. Does what position:sticky can't
Stars: ✭ 1,193 (+5322.73%)
Mutual labels:  scrolling, header, sticky
Stickyheaderlistview
打造炫酷列表之 StickyHeaderListView:标题渐变、吸附悬浮、筛选分类、动态头部等
Stars: ✭ 2,820 (+12718.18%)
Mutual labels:  header, sticky
Fixed Sticky
DEPRECATED: A position: sticky polyfill that works with filamentgroup/fixed-fixed for a safer position:fixed fallback.
Stars: ✭ 1,490 (+6672.73%)
Mutual labels:  scrolling, sticky
Sticky State
StickyState is a high performant module making native position:sticky statefull and polyfilling the missing sticky browser feature
Stars: ✭ 692 (+3045.45%)
Mutual labels:  scrolling, sticky
react-sticky-header
🍯 A sticky header for React.js
Stars: ✭ 55 (+150%)
Mutual labels:  header, sticky
clever-infinite-scroll
A useful infinite scroll jQuery plugin. It changes title and URL automatically, it's nice for SEO.
Stars: ✭ 56 (+154.55%)
Mutual labels:  scrolling
styled-minimal
Minimal UI theme with styled-components
Stars: ✭ 18 (-18.18%)
Mutual labels:  styled-components
dashboard
🐥 McHacks dashboard
Stars: ✭ 28 (+27.27%)
Mutual labels:  styled-components
babel-plugin-object-styles-to-template
Babel plugin to transpile object styles to template literal
Stars: ✭ 33 (+50%)
Mutual labels:  styled-components
molecule
⚛️ –  – ⚛️ Boilerplate for cross platform web/native react apps with electron.
Stars: ✭ 95 (+331.82%)
Mutual labels:  styled-components
react-native-infinite-scroll
A simple implementation of infinite scrolling for React Native.
Stars: ✭ 19 (-13.64%)
Mutual labels:  scrolling
coincharts
Cryptocurrency Price Chart (GDAX)
Stars: ✭ 75 (+240.91%)
Mutual labels:  styled-components
react-2048
A React implementation of 2048 game built with typescript and styled-components
Stars: ✭ 66 (+200%)
Mutual labels:  styled-components
gatsby-personal-site
My personal site made with Gatsby
Stars: ✭ 31 (+40.91%)
Mutual labels:  styled-components
chat
💬 A React single page chat application (SPA), implementing Socket.io.
Stars: ✭ 98 (+345.45%)
Mutual labels:  styled-components
use-scroll-direction
A simple, performant, and cross-browser hook for detecting scroll direction in your next react app.
Stars: ✭ 24 (+9.09%)
Mutual labels:  scrolling
blue-collar-rocket
I built this as a capstone project of our web development boot camp. Blue Collar Rocket is an app to streamline processes in craftsmanship.
Stars: ✭ 13 (-40.91%)
Mutual labels:  styled-components
ng2-go-top-button
A simple customizable go-top-button component for Angular projects.
Stars: ✭ 18 (-18.18%)
Mutual labels:  scrolling
reactube-client
A clone Youtube Web Player using React Provider Pattern, React Context and Typescript
Stars: ✭ 92 (+318.18%)
Mutual labels:  styled-components
styless
Style your components declaratively with familiar less syntax
Stars: ✭ 64 (+190.91%)
Mutual labels:  styled-components

ReactStickyHeadroom

npm badge

ReactStickyHeadroom is a React component, that hides your header when you scroll down and shows it once you're scrolling up again. It's designed for best performance and can only be used if you know the height of your header component (or more precisely the amount of pixels you want ReactStickyHeadroom to hide). This helps us avoid calculating the height ourselves and therefore browsers don't need to perform heavy Recalculate-Style-Phases. For more information read here.

Since it's using styled-components internally, it's best to use it in apps where you already have styled-components in place. The component is only compatible with styled-components v4 and higher.

The component is inspired by react-headroom.

Usage

A basic usage example:

render () {
  return <StickyHeadroom scrollHeight={100}>
    <div style={{height: '100px', backgroundColor: 'red'}}>MyHeader</div>
  </StickyHeadroom>
}

Demo

Go to https://digitalfabrik.github.io/react-sticky-headroom/ to view a demo:

Demo

API

You can pass the following props to ReactStickyHeadroom:

  • children: React.Node The header component, that should be hidden and revealed
  • scrollHeight: number The maximum amount of px the header should move up when scrolling
  • pinStart: number (Default: 0) The minimum scrollTop position where the transform should start
  • height?: number (Optional) The height of the children node. Used for calculating the stickyTop position for a sticky ancestor in onStickyTopChanged
  • onStickyTopChanged?: (number) => void Fired, when Headroom changes its state and height is provided. Passes the calculated stickyTop position of an ancestor node.
  • positionStickyDisabled?: boolean (Optional, Default: false) If true, the header will stay static (e.g. for edge 16 support)
  • parent: ?HTMLElement (Optional, Default: document.documentElement) The parent element firing the scroll event.
  • zIndex: number (Optional, Default: 1) The z-index used by the wrapper.
  • className?: string (Optional) A classname for applying custom styles to the wrapper. Use at your own risk.

Support

The component generally supports:

  • Internet Explorer 11
  • Edge >= 16
  • Chrome >= 41
  • Firefox >= 40
  • Safari >= 6.2

For hiding and revealing the header, the browser needs to support the css-property position: sticky. You can read about the browser support for that on caniuse.com. 'Partial-Support' is enough for ReactStickyHeadroom to work in most cases.

ReactStickyHeadroom offers types for both TypeScript and FlowJS which should work out of the box.

If there are any problems, please don't hesitate to open an issue on GitHub.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].