Skip to content

Commit

Permalink
Fix thread-view scroll highlighted into view
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee committed May 4, 2021
1 parent 28644c5 commit dc525c4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions static/js/com/thread.js
Expand Up @@ -91,16 +91,15 @@ export class Thread extends LitElement {
}
}

scrollHighlightedPostIntoView () {
async scrollHighlightedPostIntoView () {
try {
await this.requestUpdate()
const el = this.querySelector('.highlight')
const y = el.getBoundingClientRect().top - 50
window.scrollTo(0, y)
setTimeout(() => {
if (Math.abs(window.scrollY - y) > 10) {
window.scrollTo(0, y)
}
}, 500)
while (Math.abs(window.scrollY - y) > 10) {
window.scrollTo(0, y)
await new Promise(r => setTimeout(r, 100))
}
} catch (e) { /* ignore */ }
}

Expand Down

0 comments on commit dc525c4

Please sign in to comment.