Merge pull request #92 from hyrious/master

允许 `autoSpacing` 在 DOM ready 后调用
This commit is contained in:
Sivan 2022-06-21 02:17:50 +08:00 committed by GitHub
commit 8fab6851db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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