20 lines
579 B
TypeScript
Raw Normal View History

2018-04-02 05:34:16 +00:00
import AnimeNotifier from "../AnimeNotifier"
import { requestIdleCallback } from "../Utils"
2017-10-17 09:27:15 +00:00
// Load
export function load(arn: AnimeNotifier, element: HTMLElement) {
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
arn.app.load(url)
}
// Diff
export function diff(arn: AnimeNotifier, element: HTMLElement) {
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
2017-11-10 07:41:45 +00:00
2017-11-03 17:10:31 +00:00
arn.diff(url)
2017-11-10 07:41:45 +00:00
.then(() => {
// Avoid instant layout thrashing
2018-04-02 05:34:16 +00:00
requestIdleCallback(() => arn.scrollTo(element))
2017-11-10 07:41:45 +00:00
})
2017-11-03 17:10:31 +00:00
.catch(console.error)
2017-10-17 09:27:15 +00:00
}