fix: use tick() for panel scroll reset on video switch
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { onMount } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
|
|
||||||
let videos = $state([]);
|
let videos = $state([]);
|
||||||
let selectedVideo = $state(null);
|
let selectedVideo = $state(null);
|
||||||
@@ -58,6 +58,13 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$effect(() => { if (activeTab) loadVideos(); });
|
$effect(() => { if (activeTab) loadVideos(); });
|
||||||
|
$effect(() => {
|
||||||
|
if (selectedVideo) {
|
||||||
|
tick().then(() => {
|
||||||
|
document.getElementById('summary-panel')?.scrollTo({ top: 0, behavior: 'instant' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
document.documentElement.className = theme;
|
document.documentElement.className = theme;
|
||||||
loadVideos();
|
loadVideos();
|
||||||
@@ -91,9 +98,6 @@
|
|||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
const el = document.querySelector(`[data-video-index="${index}"]`);
|
const el = document.querySelector(`[data-video-index="${index}"]`);
|
||||||
if (el) el.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
if (el) el.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||||
// Also scroll summary panel to top
|
|
||||||
const main = document.querySelector('main');
|
|
||||||
if (main) main.scrollTop = 0;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,7 +150,7 @@
|
|||||||
<div class="flex-1 overflow-y-auto divide-y" style="border-color:var(--border)">
|
<div class="flex-1 overflow-y-auto divide-y" style="border-color:var(--border)">
|
||||||
{#each videos as video (video.video_id)}
|
{#each videos as video (video.video_id)}
|
||||||
{@const i = videos.indexOf(video)}
|
{@const i = videos.indexOf(video)}
|
||||||
<button onclick={() => { selectedVideo = video; document.querySelector('main')?.scrollTo(0,0); }}
|
<button onclick={() => { selectedVideo = video; }}
|
||||||
data-video-index={i}
|
data-video-index={i}
|
||||||
class="w-full text-left p-3 transition flex items-start space-x-3"
|
class="w-full text-left p-3 transition flex items-start space-x-3"
|
||||||
style="border-left:2px solid {selectedVideo?.video_id === video.video_id ? 'var(--accent)' : 'transparent'};
|
style="border-left:2px solid {selectedVideo?.video_id === video.video_id ? 'var(--accent)' : 'transparent'};
|
||||||
@@ -163,7 +167,7 @@
|
|||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<!-- Right: summary PRIMARY -->
|
<!-- Right: summary PRIMARY -->
|
||||||
<main class="flex-1 overflow-y-auto" style="background:var(--bg-primary)">
|
<main id="summary-panel" class="flex-1 overflow-y-auto" style="background:var(--bg-primary)">
|
||||||
{#if selectedVideo}
|
{#if selectedVideo}
|
||||||
<div class="p-6 max-w-3xl mx-auto space-y-4">
|
<div class="p-6 max-w-3xl mx-auto space-y-4">
|
||||||
<!-- ★ AI Digest -->
|
<!-- ★ AI Digest -->
|
||||||
|
|||||||
Reference in New Issue
Block a user