Skip to content

Commit

Permalink
fix: default scroll end
Browse files Browse the repository at this point in the history
  • Loading branch information
JaeAiKay committed Aug 31, 2024
1 parent 7ff0f17 commit 291e0db
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/components/Assemblies/CabinetChanges/TimeLine.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import Tooltip from '../Tooltip.svelte';
import TimeLineToolTip from './TimeLineToolTip.svelte';
import { shortMonthNames } from '$lib/date-parser';
import { afterUpdate, onMount } from 'svelte';
export let timeLineData: TimeLine[];
export let startedAt: Date | null;
Expand All @@ -17,6 +18,7 @@
$: dateData = getDateData(timeLineData, startedAt, endedAt);
let timelineContainer: HTMLDivElement;
let prevstartedAt: Date | null;
const handleNext = () => {
timelineContainer.scrollBy({ left: -timelineContainer.clientWidth, behavior: 'smooth' });
Expand All @@ -25,6 +27,23 @@
const handlePrev = () => {
timelineContainer.scrollBy({ left: timelineContainer.clientWidth, behavior: 'smooth' });
};
const scrollToEnd = () => {
if (timelineContainer) {
timelineContainer.scrollTo({ left: timelineContainer.scrollWidth, behavior: 'smooth' });
}
};
onMount(() => {
scrollToEnd();
});
afterUpdate(() => {
if (startedAt !== prevstartedAt) {
scrollToEnd();
prevstartedAt = startedAt;
}
});
</script>

<div class="relative">
Expand Down
2 changes: 1 addition & 1 deletion src/routes/assemblies/[id]/changes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
$: ({ assembly, availableAssemblies, assemblyRoles, cabinetMembers, changes } = data);
$: selectedDate = new Date();
$: selectedDate = assembly.endedAt || new Date();
const handleSelectDate = (date: Date) => {
selectedDate = date;
};
Expand Down

0 comments on commit 291e0db

Please sign in to comment.