You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+41-21Lines changed: 41 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
# Vue Use Fixed Header
4
4
5
-
Turn your boring fixed header into a smart one with one line of code.
5
+
Turn your boring fixed header into a smart one with three lines of code.
6
6
7
7
<br />
8
8
@@ -12,13 +12,12 @@ Turn your boring fixed header into a smart one with one line of code.
12
12
13
13
## Features
14
14
15
-
-**Dead simple** - Call a function and you're done whether you're SSR'ing or not
16
-
-**Lightweight** - Just over 1kb without any dependency
17
-
-**Enjoyable** - When scrolling down, the header is hidden, when scrolling up, the header is shown.
18
-
-**Powerful** - Uses acceleration delta for both hiding and showing instead of fixed thresholds
19
-
-**User-centric** - Behaves as your users expect on page load, scroll restoration, hovering, dropdown navigation, top reached and reduced motion.
15
+
-**Dead simple** - Write three lines of code and you're done.
16
+
-**Enjoyable defaults** - When scrolling down, the header is hidden, when scrolling up, the header is shown.
17
+
-**Powerful** - Uses acceleration delta (scroll speed) for both hiding and showing instead of fixed thresholds.
18
+
-**Intuitive** - Behaves as expected on page load, scroll restoration, hovering, dropdown navigation, top-reached and reduced motion.
20
19
-**Smart** - Functionalities are automatically enabled/disabled if your header turns from fixed/sticky to something else or it is hidden at different viewports
21
-
-**Flexible** - Works with any scrolling container and with your own transition styles
20
+
-**Flexible** - Works with any scrolling container and with your own styles
22
21
23
22
<br />
24
23
@@ -28,11 +27,21 @@ Turn your boring fixed header into a smart one with one line of code.
28
27
pnpm add vue-use-fixed-header
29
28
```
30
29
30
+
Or:
31
+
32
+
```bash
33
+
yarn add vue-use-fixed-header
34
+
```
35
+
36
+
```bash
37
+
npm i vue-use-fixed-header
38
+
```
39
+
31
40
<br />
32
41
33
42
## Usage
34
43
35
-
Pass your header's template ref to `useFixedHeader`. Then style it as you normally would. That's it.
44
+
Pass your header's template ref to `useFixedHeader`. Then apply the returned reactive styles. That's it.
36
45
37
46
```vue
38
47
<script setup>
@@ -41,11 +50,11 @@ import { useFixedHeader } from 'vue-use-fixed-header'
As long as your header position is set to fixed/sticky, it will behave as described in the [features](#features) section.
63
-
64
-
> :warning: There's only **one rule** to respect: Do not apply any _transition-related_ property since they're handled internally. See [below](#customization) how to customize them.
71
+
All you have to do is to set `position: fixed` (or `sticky`) to your header. `useFixedHeader` will take care of the rest.
65
72
66
73
<br />
67
74
68
75
## Automatic behavior toggling
69
76
70
77
On resize, `useFixedHeader` checks your header's `position` and `display` properties to determine whether its functionalities should be enabled or not.
71
78
72
-
_Disabled_ means that the header will behave as you're not using the composable at all: no event listeners are attached and no additional styles are applied.
79
+
_Disabled_ means that no event listeners are attached and the returned styles match an empty object `{}`.
73
80
74
81
### Different viewports
75
82
76
-
If at different viewports your header position is not fixed/sticky (or it is hidden), functionalities are automatically toggled when needed.
0 commit comments