Improved navigation performance

This commit is contained in:
Eduard Urbach 2018-04-20 10:13:49 +02:00
parent 9d06309dc1
commit dd10b8e1e4

View File

@ -239,13 +239,12 @@ export default class AnimeNotifier {
assignTooltipOffsets(elements?: IterableIterator<HTMLElement>) { assignTooltipOffsets(elements?: IterableIterator<HTMLElement>) {
const distanceToBorder = 5 const distanceToBorder = 5
let contentRect: ClientRect
if(!elements) { if(!elements) {
elements = findAll("tip") elements = findAll("tip")
} }
let contentRect = this.app.content.getBoundingClientRect()
for(let element of elements) { for(let element of elements) {
element.onmouseenter = () => { element.onmouseenter = () => {
if(element.dataset.offsetAssigned) { if(element.dataset.offsetAssigned) {
@ -254,6 +253,10 @@ export default class AnimeNotifier {
} }
Diff.mutations.queue(() => { Diff.mutations.queue(() => {
if(!contentRect) {
contentRect = this.app.content.getBoundingClientRect()
}
let rect = element.getBoundingClientRect() let rect = element.getBoundingClientRect()
let tipStyle = window.getComputedStyle(element, ":before") let tipStyle = window.getComputedStyle(element, ":before")
let tipWidth = parseInt(tipStyle.width) + parseInt(tipStyle.paddingLeft) * 2 let tipWidth = parseInt(tipStyle.width) + parseInt(tipStyle.paddingLeft) * 2