|
36 | 36 | <p><strong>Hide your header and footer until you need them!</strong></p> |
37 | 37 | <p>Svelte Headroom is a <a href="https://svelte.dev" rel="nofollow">Svelte</a> component to hide or show your header on scroll, based on <a href="https://github.com/collardeau/svelte-headroom">collardeau/svelte-headroom</a>, inspired by <a href="https://wicky.nillia.ms/headroom.js/" rel="nofollow">headroom.js</a></p> |
38 | 38 | <p><code>@taocode/svelte-headroom</code> has <strong>no dependencies</strong>.</p> |
39 | | - <h1>Demo</h1> |
40 | | - <p><a href="https://codesandbox.io/embed/svelte-headroom-demo-cf7lv" rel="nofollow">Code Sandbox</a></p> |
41 | | - <h1>Install</h1> |
| 39 | + <h2>Demo</h2> |
| 40 | + <p><a href="https://svelte.dev/repl/44cafd471bcf497080e12ed3bee80986" rel="nofollow">SVELTE REPL</a></p> |
| 41 | + <h2>Install</h2> |
42 | 42 | <p><code>npm install @taocode/svelte-headroom</code></p> |
43 | 43 | <h2>Usage</h2> |
44 | 44 | <div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto"><pre> |
|
57 | 57 | <span class="pl-c"><!-- my header --></span> |
58 | 58 | <span class="pl-kos"></</span><span class="pl-ent">Headroom</span><span class="pl-kos">></span></pre></div> |
59 | 59 | <h3><code>tolerance</code> number</h3> |
60 | | - <p>The amount 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: <code>0</code>.</p> |
| 60 | + <p>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: <code>0</code>.</p> |
61 | 61 | <div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto"><pre> |
62 | 62 | <span class="pl-kos"><</span><span class="pl-ent">Headroom</span> <span class="pl-c1">tolerance</span>=<span class="pl-s">{10}</span><span class="pl-kos">></span> |
63 | 63 | <span class="pl-c"><!-- my header --></span> |
64 | 64 | <span class="pl-kos"></</span><span class="pl-ent">Headroom</span><span class="pl-kos">></span></pre></div> |
| 65 | + <h3><code>shim</code> number</h3> |
| 66 | + <p>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: <code>2</code>.</p> |
| 67 | + <div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto"><pre> |
| 68 | + <span class="pl-kos"><</span><span class="pl-ent">Headroom</span> <span class="pl-c1">shim</span>=<span class="pl-s">{5}</span><span class="pl-kos">></span> |
| 69 | + <span class="pl-c"><!-- my header --></span> |
| 70 | + <span class="pl-kos"></</span><span class="pl-ent">Headroom</span><span class="pl-kos">></span></pre></div> |
65 | 71 | <h3><code>duration</code> string</h3> |
66 | 72 | <p>The duration of the sliding effect. The value is passed on as a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transition-duration" rel="nofollow">CSS Transition Duration</a>. Default: <code>"300ms"</code>.</p> |
67 | 73 | <div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto"><pre> |
68 | 74 | <span class="pl-kos"><</span><span class="pl-ent">Headroom</span> <span class="pl-c1">duration</span>='<span class="pl-s">500ms</span>'<span class="pl-kos">></span> |
69 | 75 | <span class="pl-c"><!-- my header --></span> |
70 | 76 | <span class="pl-kos"></</span><span class="pl-ent">Headroom</span><span class="pl-kos">></span></pre></div> |
71 | 77 |
|
| 78 | + <h3><code>easing</code> string</h3> |
| 79 | + <p>The easing of the sliding effect. The value is passed on as a <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transition-timing-function" rel="nofollow">CSS Transition Timing Function</a>. Default: <code>"linear"</code>.</p> |
| 80 | + <div class="highlight highlight-text-html-basic notranslate position-relative overflow-auto"><pre> |
| 81 | + <span class="pl-kos"><</span><span class="pl-ent">Headroom</span> <span class="pl-c1">easing</span>='<span class="pl-s">ease-out</span>'<span class="pl-kos">></span> |
| 82 | + <span class="pl-c"><!-- my header --></span> |
| 83 | + <span class="pl-kos"></</span><span class="pl-ent">Headroom</span><span class="pl-kos">></span></pre></div> |
72 | 84 |
|
73 | 85 | <h3><code>bottom</code> boolean</h3> |
74 | 86 | <p>If this is to be pinned to the bottom, like a return to top button. Default: false.</p> |
|
0 commit comments