fix: scroller fix!

This commit is contained in:
Tim
2025-08-05 19:44:59 +08:00
parent 7fe37d0131
commit eb933b8f78
2 changed files with 9 additions and 7 deletions

View File

@@ -56,7 +56,8 @@ body {
font-family: 'Roboto', sans-serif; font-family: 'Roboto', sans-serif;
background-color: var(--normal-background-color); background-color: var(--normal-background-color);
color: var(--text-color); color: var(--text-color);
/* overflow: hidden; 禁止滚动 */ /* 禁止滚动 */
/* overflow: hidden; */
} }
/************************* /*************************

View File

@@ -156,6 +156,7 @@ export default {
const defaultTitle = document.title const defaultTitle = document.title
const metaDescriptionEl = document.querySelector('meta[name="description"]') const metaDescriptionEl = document.querySelector('meta[name="description"]')
const defaultDescription = metaDescriptionEl ? metaDescriptionEl.getAttribute('content') : '' const defaultDescription = metaDescriptionEl ? metaDescriptionEl.getAttribute('content') : ''
const headerHeight = parseFloat(getComputedStyle(document.documentElement).getPropertyValue('--header-height')) || 0
watch(title, t => { watch(title, t => {
document.title = `OpenIsle - ${t}` document.title = `OpenIsle - ${t}`
@@ -358,8 +359,8 @@ export default {
currentIndex.value = index currentIndex.value = index
const target = postItems.value[index - 1] const target = postItems.value[index - 1]
if (target) { if (target) {
const top = getTop(target) const top = getTop(target) - headerHeight - 20 // 20 for beauty
window.scrollTo({ top, behavior: 'instant' }) window.scrollTo({ top, behavior: 'auto' })
} }
} }
@@ -568,10 +569,10 @@ export default {
await nextTick() await nextTick()
const el = document.getElementById('comment-' + id) const el = document.getElementById('comment-' + id)
if (el) { if (el) {
const top = el.getBoundingClientRect().top + window.scrollY const top = el.getBoundingClientRect().top + window.scrollY - headerHeight - 20 // 20 for beauty
window.scrollTo({ top, behavior: 'instant' }) window.scrollTo({ top, behavior: 'smooth' })
el.classList.add('comment-highlight') el.classList.add('comment-highlight')
setTimeout(() => el.classList.remove('comment-highlight'), 2000) setTimeout(() => el.classList.remove('comment-highlight'), 4000)
} }
} }
} }
@@ -668,7 +669,7 @@ export default {
flex-direction: column; flex-direction: column;
width: 15%; width: 15%;
position: sticky; position: sticky;
top: 0; top: var(--header-height);
align-self: flex-start; align-self: flex-start;
} }