perf: improve scroll performance
https://developers.google.com/web/updates/2016/06/passive-event-listeners
This commit is contained in:
parent
20704eba75
commit
d9d09c4e8f
1 changed files with 3 additions and 3 deletions
|
@ -140,14 +140,14 @@ export class BtnList {
|
||||||
const anchorDiv = this.getBtnParent()
|
const anchorDiv = this.getBtnParent()
|
||||||
const pos = () => this._positionBtns(anchorDiv, newParent)
|
const pos = () => this._positionBtns(anchorDiv, newParent)
|
||||||
pos()
|
pos()
|
||||||
document.addEventListener('readystatechange', pos)
|
document.addEventListener('readystatechange', pos, { passive: true })
|
||||||
|
|
||||||
// reposition btns when window resizes
|
// reposition btns when window resizes
|
||||||
window.addEventListener('resize', pos)
|
window.addEventListener('resize', pos, { passive: true })
|
||||||
|
|
||||||
// reposition btns when scrolling
|
// reposition btns when scrolling
|
||||||
const scroll = getScrollParent(anchorDiv)
|
const scroll = getScrollParent(anchorDiv)
|
||||||
scroll.addEventListener('scroll', pos)
|
scroll.addEventListener('scroll', pos, { passive: true })
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue