Skip to content

Commit 8ee16d0

Browse files
committed
docs(props): corrected readme and dev +page
1 parent 884a98f commit 8ee16d0

File tree

2 files changed

+38
-37
lines changed

2 files changed

+38
-37
lines changed

README.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ Svelte Headroom is a [Svelte](https://svelte.dev) component to hide or show your
88

99
## Demo
1010

11-
Demo URL coming soon or check the source.
12-
13-
[Svelte REPL](https://svelte.dev/repl/44cafd471bcf497080e12ed3bee80986?version=3.53.1)
11+
[Svelte REPL](https://svelte.dev/repl/44cafd471bcf497080e12ed3bee80986?version=3.53.1) or check the source: `src/routes/+page.svelte`
1412

1513
## Install
1614

@@ -31,38 +29,37 @@ Demo URL coming soon or check the source.
3129

3230
## Props
3331

34-
### `offset` number
32+
### `tolerance` number
3533

36-
The number of pixels from the top of the page before the effect is allowed to occur. Default: `0`.
34+
The number of pixels that need to be scrolled in either direction for the effect to occur. This is useful if you want the user to be able to scroll slowly and not change the header position. Default: `0`.
3735

3836
```html
3937

40-
<Headroom offset={50}>
41-
<!-- my header -->
38+
<Headroom tolerance={10}>
39+
<!-- will ignore any scroll less than 10px -->
4240
</Headroom>
4341

4442
```
43+
### `offsetTop` number
4544

46-
### `tolerance` number
47-
48-
The number of pixels that need to be scrolled in either direction for the effect to occur. This is useful if you want the user to be able to scroll slowly and not change the header position. Default: `0`.
45+
The number of pixels from the top of the page before the effect is allowed to occur; *controls:* `class:atTop` (useful with hideAtTop, showAtTop). Default: `2`.
4946

5047
```html
5148

52-
<Headroom tolerance={10}>
53-
<!-- my header -->
49+
<Headroom offsetTop={50}>
50+
<!-- will show until after 50px from top -->
5451
</Headroom>
5552

5653
```
5754

58-
### `shim` number
55+
### `offsetBottom` number
5956

60-
The number of pixels from top or bottom to detect top or bottom status. If you're within this value of top or bottom, you'll be considered at top or bottom. Default: `2`.
57+
The number of pixels from bottom to be considered at the bottom; *controls* `class:atBottom` (useful with hideAtBottom, showAtBottom). Default: `2`.
6158

6259
```html
6360

64-
<Headroom shim={5}>
65-
<!-- my header -->
61+
<Headroom showAtBottom offsetBottom={150}>
62+
<!-- will show when within 150px of bottom -->
6663
</Headroom>
6764

6865
```
@@ -74,7 +71,7 @@ The duration of the sliding effect. The value is passed on as a [CSS Transition
7471
```html
7572

7673
<Headroom duration='500ms'>
77-
<!-- my header -->
74+
<!-- will take 500ms to transition -->
7875
</Headroom>
7976

8077
```
@@ -86,7 +83,7 @@ The timing function (easing) of the sliding effect. The value is passed on as a
8683
```html
8784

8885
<Headroom easing='ease-out'>
89-
<!-- my header -->
86+
<!-- will ease-out -->
9087
</Headroom>
9188

9289
```
@@ -98,7 +95,7 @@ If this is to be pinned to the bottom, like a return to top button. Default: `fa
9895
```html
9996

10097
<Headroom bottom>
101-
<!-- my header -->
98+
<!-- pinned to the bottom -->
10299
</Headroom>
103100

104101
```
@@ -119,7 +116,7 @@ If this is to be pinned to the bottom, like a return to top button. Default: `fa
119116

120117
```
121118

122-
# Events
119+
## Events
123120

124121
A `svelte-headroom` component emits two events: `pin` and `unpin`.
125122

src/routes/+page.svelte

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script>
2-
import {
3-
Headroom
4-
} from '$lib'
2+
import { Headroom } from '$lib'
53
64
function onPin() {
75
console.log('pin')
@@ -13,7 +11,7 @@
1311
pinned = false
1412
}
1513
16-
const props = ['tolerance','offsetTop','offsetBottom','duration','easing','bottom',['ats','(hide|show)at(Top|Bottom)']]
14+
const propsMenu = ['tolerance','offsetTop','offsetBottom','duration','easing','bottom',['ats','(hide|show)at(Top|Bottom)']]
1715
let pinned = true
1816
</script>
1917

@@ -27,7 +25,7 @@
2725
<div class="topmenu">
2826
<div class="label">props:</div>
2927
<nav class="menu">
30-
{#each props as p}
28+
{#each propsMenu as p}
3129
{#if Array.isArray(p)}
3230
<a href="#{p[0]}">{p[1]}</a>
3331
{:else}
@@ -40,7 +38,7 @@
4038
</Headroom>
4139

4240
<div class="totop-wrap">
43-
<Headroom bottom showAtBottom hideAtTop tolerance={20} offsetTop={200} offsetBottom={100}>
41+
<Headroom bottom showAtBottom hideAtTop tolerance={20} offsetTop={100} offsetBottom={100}>
4442
<button class="totop" on:click={()=> window.scroll(0,0)}> <span class="caret">^</span> <span>To Top</span> </button>
4543
</Headroom>
4644
</div>
@@ -53,7 +51,7 @@
5351
by <a href="https://wicky.nillia.ms/headroom.js/" rel="nofollow">headroom.js</a></p>
5452
<p><code>@taocode/svelte-headroom</code> has <strong>no dependencies</strong>.</p>
5553
<h2>Demo</h2>
56-
<p><a href="https://svelte.dev/repl/44cafd471bcf497080e12ed3bee80986" rel="nofollow">SVELTE REPL</a></p>
54+
<p><a href="https://svelte.dev/repl/44cafd471bcf497080e12ed3bee80986?version=3" rel="nofollow">SVELTE REPL</a></p>
5755
<h2>Install</h2>
5856
<p><code>npm install @taocode/svelte-headroom</code></p>
5957
<h2>Usage</h2>
@@ -70,28 +68,28 @@
7068
<h2>Props</h2>
7169
<h3 id="tolerance"><code>tolerance</code> number</h3>
7270
<p>The number of pixels that need to be scrolled in either direction for the effect to occur. This is useful if you
73-
want the user to be able to scroll slowly and not trigger . Default: <code>0</code>.</p>
71+
want the user to be able to scroll slowly and not trigger un/pin event. Default: <code>0</code>.</p>
7472
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
7573
<pre>
7674
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">tolerance</span>=<span class="pl-s">&lbrace;10&rbrace;</span><span class="pl-kos">&gt;</span>
77-
<span class="pl-c">&lt;!-- my header --&gt;</span>
75+
<span class="pl-c">&lt;!-- will ignore any scroll less than 10px --&gt;</span>
7876
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
7977
</div>
8078
<h3 id="offsetTop"><code>offsetTop</code> number</h3>
81-
<p>The number of pixels from the top of the page before the effect is allowed to occur and is the threshold for class:atTop. Default: <code>2</code>.</p>
79+
<p>The number of pixels from the top of the page before the effect is allowed to occur; <em>controls</em> `class:atTop` (used with hideAtTop, showAtTop) Default: <code>2</code>.</p>
8280
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
8381
<pre>
8482
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">offsetTop</span>=<span class="pl-s">&lbrace;50&rbrace;</span><span class="pl-kos">&gt;</span>
85-
<span class="pl-c">&lt;!-- my header --&gt;</span>
83+
<span class="pl-c">&lt;!-- will show until after 50px from top --&gt;</span>
8684
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
8785
</div>
8886
<h3 id="offsetBottom"><code>offsetBottom</code> number</h3>
89-
<p>The number of pixels from top to still be considered at the bottom (useful with hideAtTop, showAtTop, etc...).
87+
<p>The number of pixels from top to still be considered at the bottom; <em>controls:</em> `class:atBottom` (used with hideAtBottom, showAtBottom).
9088
Default: <code>2</code>.</p>
9189
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
9290
<pre>
93-
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">offsetBottom</span>=<span class="pl-s">&lbrace;5&rbrace;</span><span class="pl-kos">&gt;</span>
94-
<span class="pl-c">&lt;!-- my header --&gt;</span>
91+
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> showAtBottom <span class="pl-c1">offsetBottom</span>=<span class="pl-s">&lbrace;150&rbrace;</span><span class="pl-kos">&gt;</span>
92+
<span class="pl-c">&lt;!-- will show when within 150px of bottom --&gt;</span>
9593
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
9694
</div>
9795
<h3 id="duration"><code>duration</code> string</h3>
@@ -101,7 +99,7 @@
10199
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
102100
<pre>
103101
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">duration</span>='<span class="pl-s">500ms</span>'<span class="pl-kos">&gt;</span>
104-
<span class="pl-c">&lt;!-- my header --&gt;</span>
102+
<span class="pl-c">&lt;!-- will take 500ms to transition --&gt;</span>
105103
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
106104
</div>
107105

@@ -112,7 +110,7 @@
112110
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
113111
<pre>
114112
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">easing</span>='<span class="pl-s">ease-out</span>'<span class="pl-kos">&gt;</span>
115-
<span class="pl-c">&lt;!-- my header --&gt;</span>
113+
<span class="pl-c">&lt;!-- will ease-out --&gt;</span>
116114
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
117115
</div>
118116

@@ -121,7 +119,7 @@
121119
<div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto">
122120
<pre>
123121
<span class="pl-kos">&lt;</span><span class="pl-ent">Headroom</span> <span class="pl-c1">bottom</span><span class="pl-kos">&gt;</span>
124-
<span class="pl-c">&lt;!-- my header --&gt;</span>
122+
<span class="pl-c">&lt;!-- pinned to the bottom --&gt;</span>
125123
<span class="pl-kos">&lt;/</span><span class="pl-ent">Headroom</span><span class="pl-kos">&gt;</span></pre>
126124
</div>
127125

@@ -183,7 +181,13 @@
183181
}
184182
.topmenu .label {
185183
text-transform: uppercase;
184+
transform: rotate(-45deg) scaleX(0.85) skewX(-20deg);
186185
}
186+
@media screen and (min-width: 700px) {
187+
.topmenu .label {
188+
transform: rotate(0);
189+
}
190+
}
187191
188192
.menu {
189193
display: flex;

0 commit comments

Comments
 (0)