-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve examples and add docs for UseAutoScroll
- Loading branch information
Showing
5 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script lang="ts"> | ||
import { Subheading } from '$lib/components/docs'; | ||
import Installation from '$lib/components/installation.svelte'; | ||
import { Code } from '$lib/components/ui/code'; | ||
</script> | ||
|
||
<Installation specifier={'hooks/use-auto-scroll.svelte'} /> | ||
<Subheading>Usage</Subheading> | ||
<p>Create a container that automatically scrolls to the bottom.</p> | ||
<Code | ||
lang="svelte" | ||
highlight={[2, 6, 10, 13, 14]} | ||
code={`\<script lang="ts"\> | ||
import { UseAutoScroll } from '$lib/hooks/use-auto-scroll.svelte'; | ||
let { children } = $props(); | ||
const autoScroll = new UseAutoScroll(); | ||
\<\/script\> | ||
<div> | ||
<div bind:this={autoScroll.ref}> | ||
{@render children?.()} | ||
</div> | ||
{#if !autoScroll.isAtBottom} | ||
<button onclick={() => autoScroll.scrollToBottom()}> | ||
Scroll To Bottom | ||
</button> | ||
{/if} | ||
</div>`} | ||
/> |