fix autoSpacing to take effect after DOM ready

This commit is contained in:
hyrious 2022-06-15 09:37:29 +08:00
parent eadee6a3b7
commit c82e86bc4b
No known key found for this signature in database
GPG key ID: C179534D85C63325

View file

@ -118,13 +118,15 @@ class Heti {
} }
autoSpacing () { autoSpacing () {
document.addEventListener('DOMContentLoaded', () => { const callback = () => {
const $$rootList = document.querySelectorAll(this.rootSelector) const $$rootList = document.querySelectorAll(this.rootSelector)
for (let $$root of $$rootList) { for (let $$root of $$rootList) {
this.spacingElement($$root) this.spacingElement($$root)
} }
}) }
if (document.readyState === 'complete') setTimeout(callback)
else document.addEventListener('DOMContentLoaded', callback)
} }
} }