scroll first chagned line into view

This commit is contained in:
Nikita Galaiko 2023-03-16 14:35:59 +01:00
parent bc9c2dd25d
commit a03799f35b
No known key found for this signature in database
GPG Key ID: EBAB54E845BA519D
2 changed files with 12 additions and 3 deletions

View File

@ -48,7 +48,7 @@
};
</script>
<div class="diff-listing w-full font-mono whitespace-pre select-text">
<div class="diff-listing w-full select-text whitespace-pre font-mono">
{#each diffRows.rows as row}
{@const baseNumber =
row.type === RowType.Equal || row.type === RowType.Deletion
@ -67,7 +67,11 @@
>
{row.type === RowType.Addition ? '+' : row.type === RowType.Deletion ? '-' : ''}
</div>
<div class="px-1 diff-line-{row.type}" data-line-number={curNumber}>
<div
class:line-changed={row.type === RowType.Addition || row.type === RowType.Deletion}
class="px-1 diff-line-{row.type}"
data-line-number={curNumber}
>
{#each renderRowContent(row) as content}
{@html content}
{/each}

View File

@ -242,10 +242,15 @@
}
function scrollToSession() {
let sessionEl = document.getElementById('currentSession');
const sessionEl = document.getElementById('currentSession');
if (sessionEl) {
sessionEl.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
const changedLines = document.getElementsByClassName('line-changed');
if (changedLines.length > 0) {
changedLines[0].scrollIntoView({ behavior: 'smooth', block: 'center' });
}
}
// player