Expose tDocLoader.stop() to prevent unneeded observation
This commit is contained in:
parent
c1338e63d1
commit
a717e632c6
|
@ -66,17 +66,26 @@ function tNodeList(nodes) {
|
|||
|
||||
function tDocLoader() {
|
||||
// localize HEAD
|
||||
tNodeList(document.querySelectorAll("*"));
|
||||
tNodeList(document.all);
|
||||
|
||||
// localize BODY
|
||||
var observer = new MutationObserver(function(mutations) {
|
||||
const observer = new MutationObserver(function(mutations) {
|
||||
for (var m = 0; m < mutations.length; m++) {
|
||||
tNodeList(mutations[m].addedNodes);
|
||||
}
|
||||
});
|
||||
|
||||
const onLoad = () => {
|
||||
tDocLoader.stop();
|
||||
tNodeList(document.all);
|
||||
};
|
||||
tDocLoader.start = () => {
|
||||
observer.observe(document, {subtree: true, childList: true});
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
};
|
||||
tDocLoader.stop = () => {
|
||||
observer.disconnect();
|
||||
tNodeList(document.querySelectorAll("*"));
|
||||
});
|
||||
document.removeEventListener('DOMContentLoaded', onLoad);
|
||||
};
|
||||
tDocLoader.start();
|
||||
document.addEventListener('DOMContentLoaded', onLoad);
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ function showStyles(styles = []) {
|
|||
.sort((a, b) => a.name < b.name ? -1 : a.name == b.name ? 0 : 1);
|
||||
const shouldRenderAll = history.state && history.state.scrollY > innerHeight;
|
||||
const renderBin = document.createDocumentFragment();
|
||||
tDocLoader.stop();
|
||||
renderStyles(0);
|
||||
// TODO: remember how many styles fit one page to display just that portion first next time
|
||||
function renderStyles(index) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user