Skip to content

Commit 20a06b6

Browse files
committed
Pkg - Drop new README
1 parent 89d3d9a commit 20a06b6

File tree

1 file changed

+35
-51
lines changed

1 file changed

+35
-51
lines changed

README.md

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@ Turn your boring fixed header into a smart one with three lines of code.
1212

1313
## Features
1414

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.
19-
- **Smart** - Functionalities are automatically enabled/disabled if your header turns from fixed/sticky to something else or it is hidden at different viewports
20-
- **Flexible** - Works with any scrolling container and with your own styles
15+
- **Dead simple** - Write three lines of code and you're ready to go
16+
- **Enjoyable** - When scrolling down, the header is hidden, when scrolling up, the header is shown.
17+
- **Smart** - Behaves as expected on page load, scroll restoration, hovering, dropdown navigation, top-reached and reduced motion.
18+
- **Dynamic** - Functionalities are automatically enabled/disabled if your header turns from fixed/sticky to something else or it is hidden at different viewports
19+
- **Flexible** - Works with any scrolling container
2120

2221
<br />
2322

@@ -27,8 +26,6 @@ Turn your boring fixed header into a smart one with three lines of code.
2726
pnpm add vue-use-fixed-header
2827
```
2928

30-
Or:
31-
3229
```bash
3330
yarn add vue-use-fixed-header
3431
```
@@ -78,9 +75,9 @@ On resize, `useFixedHeader` checks your header's `position` and `display` proper
7875

7976
_Disabled_ means that no event listeners are attached and the returned styles match an empty object `{}`.
8077

81-
### Different viewports
78+
### Media queries
8279

83-
Hence feel free to have code like this:
80+
Hence feel free to have code like this, it will just work as expected:
8481

8582
```css
8683
.Header {
@@ -102,13 +99,11 @@ Hence feel free to have code like this:
10299
}
103100
```
104101

105-
It will just work as expected.
106-
107102
### Advanced scenarios
108103

109-
Let's suppose your header in some pages is not fixed/sticky and you're using some reactive logic to style the `position` property.
104+
Let's suppose your header in some pages is not fixed/sticky and you're using some reactive logic to determine whether it should be or not.
110105

111-
You can pass a reactive source to the `watch` property of `useFixedHeader` to perform a check everytime the value changes:
106+
You can pass a signal to the `watch` property of `useFixedHeader` to perform a check everytime the value changes:
112107

113108
```vue
114109
<script setup>
@@ -136,51 +131,40 @@ useFixedHeader(headerRef, {
136131
137132
<br />
138133

139-
## Customization
140-
141-
> Default values are displayed below.
134+
## API
142135

143136
```ts
144-
const { styles, isEnter, isLeave } = useFixedHeader(headerRef, {
145-
/**
146-
*
147-
* Use `null` if content is scrolled by the window,
148-
* otherwise pass a custom scrolling container template ref */
149-
root: null,
150-
/**
151-
*
152-
* ref or computed to watch for automatic behavior toggling */
153-
watch: () => null,
154-
/**
155-
*
156-
* Minimum acceleration delta required to show the header.
157-
* An higher value means that the user has to scroll faster. */
158-
enterDelta: 0.5,
159-
/**
160-
*
161-
* Minimum acceleration delta required to hide the header */
162-
leaveDelta: 0.15,
137+
declare function useFixedHeader(
138+
target: Ref<HTMLElement | null> | HTMLElement | null
139+
options?: UseFixedHeaderOptions
140+
): {
141+
styles: Readonly<ShallowRef<CSSProperties>>
142+
isEnter: ComputedRef<boolean>
143+
isLeave: ComputedRef<boolean>
144+
}
145+
146+
interface UseFixedHeaderOptions {
163147
/**
148+
* Scrolling container. Matches `document.documentElement` if `null`.
164149
*
165-
* Whether to toggle `visibility: hidden` on leave.
166-
* Set this to `false` if you want to keep the header
167-
* visible. */
168-
toggleVisibility: true,
150+
* @default null
151+
*/
152+
root: Ref<HTMLElement | null> | HTMLElement | null
169153
/**
154+
* Signal without `.value` (ref or computed) to be watched
155+
* for automatic behavior toggling.
170156
*
171-
* Custom styles applied when scrolling up */
172-
enterStyles: {
173-
transition: `transform 0.3s cubic-bezier(0.16, 1, 0.3, 1)`,
174-
transform: 'translateY(0px)',
175-
},
157+
* @default null
158+
*/
159+
watch: Ref<T> | ComputedRef<T>
176160
/**
161+
* Whether to transition `opacity` propert from 0 to 1
162+
* and vice versa along with the `transform` property
177163
*
178-
* Custom styles applied when scrolling down */
179-
leaveStyles: {
180-
transition: `transform 0.5s cubic-bezier(0.16, 1, 0.3, 1)`,
181-
transform: 'translateY(-101%)',
182-
},
183-
})
164+
* @default false
165+
*/
166+
transitionOpacity: Ref<boolean> | boolean
167+
}
184168
```
185169

186170
<br />

0 commit comments

Comments
 (0)