# react-hideandseekmenu

> A simple hook to hide and show your site's menubar when scrolling.

Latest version **2.1.1** (published 2020-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-hideandseekmenu
pnpm add react-hideandseekmenu
yarn add react-hideandseekmenu
bun add react-hideandseekmenu
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2020-12-11 |
| First published | 2020-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tlorent |
| Maintainers | tlorent |
| Keywords | react, menubar, navigation, hide react navigation, scroll react navigation, hide react menubar, scroll react menubar |

## Links

- npm: https://www.npmjs.com/package/react-hideandseekmenu
- Repository: https://github.com/tlorent/react-hideandseekmenu
- Homepage: https://github.com/tlorent/react-hideandseekmenu#readme
- Issues: https://github.com/tlorent/react-hideandseekmenu/issues
- npm.io page: https://npm.io/package/react-hideandseekmenu

## Dependencies (2)

- [debounce](https://npm.io/package/debounce.md) ^1.2.0
- [@types/debounce](https://npm.io/package/@types/debounce.md) ^1.2.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2020-12-11
- 2.1.0 — 2020-12-10
- 2.0.1 — 2020-12-10
- 1.0.0 — 2020-12-09

## README

# react-hideandseekmenu
[![npm version](https://badge.fury.io/js/react-hideandseekmenu.svg)](https://badge.fury.io/js/react-hideandseekmenu)

A simple React hook to hide and show your site's menubar when scrolling.

![GIF showing react-hideandseekmenu](https://media.giphy.com/media/j1DcokVU0RO8qh7XJ7/giphy.gif)

## Features
🪝React Hook

## Installation

Install with NPM:

```sh
npm install react-hideandseekmenu --save
```

## Usage

#### `useHideAndSeekMenu`
```js
import { useHideAndSeekMenu } from 'react-hideandseekmenu'
```

You use this hook by passing in a `ref`. The hook will handle all the "hide and seek styling" for you by accessing `ref.curent.style` and setting inline-styles. You can pass in some [options](https://github.com/tlorent/react-hideandseekmenu/blob/master/README.md#options) to change the CSS and behaviour of the menu hiding & showing.

```js
useHideAndSeekMenu({
    ref: yourRef
})
```

```jsx
import { useHideAndSeekMenu } from 'react-hideandseekmenu'
import { useRef } from 'react'

const Navigation = () => {
    const navref = useRef<HTMLElement>(null);
    useHideAndSeekMenu({
        ref: navref,
        offset: 120,
        transitionDuration: 0.3,
    })

    return (
        <Nav ref={navref} />
    )
}
```

The hook will then handle the "hide and seek styling" of your navigation bar.

### Default stylings

```css
position: sticky;
transition: top 0.3s ease;
top: 0;
```

## Options

These options can be passed to the `useHideAndSeekMenu` hook:

| Option  | Type  | Default  | Description  |
|---|---|---|---|
| offset  | number  | 90  | The offset at which the menu should disappear  |
| debounceTime  | number  | 10  | The debounce time for the hook to be fired  |
| ref  | RefObject<HTMLElement>  | undefined  | Pass a ref to the hook to let the hook handle all the "hide and seek styling"  |
| transitionDuration  | number  | 0.3  | Set a transition duration for the CSS transition property  |
| transitionTimingFunction  | string  | ease  | Set a transition timing function for the CSS transition property  |

---
_Source: https://npm.io/package/react-hideandseekmenu · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
