Spaces:
Running
Running
Adrien Denat
commited on
Commit
•
741a217
1
Parent(s):
3aa8136
make sure conversations scroll back down on page change (#52)
Browse files
src/lib/actions/snapScrollToBottom.ts
CHANGED
@@ -1,3 +1,6 @@
|
|
|
|
|
|
|
|
1 |
/**
|
2 |
* @param node element to snap scroll to bottom
|
3 |
* @param dependency pass in a dependency to update scroll on changes.
|
@@ -25,7 +28,7 @@ export const snapScrollToBottom = (node: HTMLElement, dependency: any) => {
|
|
25 |
const options = { ...defaultOptions, ..._options };
|
26 |
const { force } = options;
|
27 |
|
28 |
-
if (!force && isDetached) return;
|
29 |
|
30 |
node.scroll({
|
31 |
top: node.scrollHeight
|
|
|
1 |
+
import { navigating } from '$app/stores';
|
2 |
+
import { get } from 'svelte/store';
|
3 |
+
|
4 |
/**
|
5 |
* @param node element to snap scroll to bottom
|
6 |
* @param dependency pass in a dependency to update scroll on changes.
|
|
|
28 |
const options = { ...defaultOptions, ..._options };
|
29 |
const { force } = options;
|
30 |
|
31 |
+
if (!force && isDetached && !get(navigating)) return;
|
32 |
|
33 |
node.scroll({
|
34 |
top: node.scrollHeight
|
src/routes/+layout.svelte
CHANGED
@@ -95,6 +95,7 @@
|
|
95 |
<div class="flex flex-col overflow-y-auto p-3 -mt-3 gap-2">
|
96 |
{#each data.conversations as conv}
|
97 |
<a
|
|
|
98 |
href="{base}/conversation/{conv.id}"
|
99 |
class="pl-3 pr-2 h-12 group rounded-lg flex-none text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-1 {conv.id ===
|
100 |
$page.params.id
|
|
|
95 |
<div class="flex flex-col overflow-y-auto p-3 -mt-3 gap-2">
|
96 |
{#each data.conversations as conv}
|
97 |
<a
|
98 |
+
data-sveltekit-noscroll
|
99 |
href="{base}/conversation/{conv.id}"
|
100 |
class="pl-3 pr-2 h-12 group rounded-lg flex-none text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 flex items-center gap-1 {conv.id ===
|
101 |
$page.params.id
|