Slightly improved diff performance

This commit is contained in:
2017-11-10 08:41:45 +01:00
parent d8367b6172
commit 44369cb916
5 changed files with 47 additions and 35 deletions

View File

@ -9,8 +9,11 @@ export function load(arn: AnimeNotifier, element: HTMLElement) {
// Diff
export function diff(arn: AnimeNotifier, element: HTMLElement) {
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
arn.diff(url)
.then(() => arn.scrollTo(element))
.then(() => {
// Avoid instant layout thrashing
arn.requestIdleCallback(() => arn.scrollTo(element))
})
.catch(console.error)
}