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() {
|
function tDocLoader() {
|
||||||
// localize HEAD
|
// localize HEAD
|
||||||
tNodeList(document.querySelectorAll("*"));
|
tNodeList(document.all);
|
||||||
|
|
||||||
// localize BODY
|
// localize BODY
|
||||||
var observer = new MutationObserver(function(mutations) {
|
const observer = new MutationObserver(function(mutations) {
|
||||||
for (var m = 0; m < mutations.length; m++) {
|
for (var m = 0; m < mutations.length; m++) {
|
||||||
tNodeList(mutations[m].addedNodes);
|
tNodeList(mutations[m].addedNodes);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
observer.observe(document, {subtree: true, childList: true});
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
const onLoad = () => {
|
||||||
|
tDocLoader.stop();
|
||||||
|
tNodeList(document.all);
|
||||||
|
};
|
||||||
|
tDocLoader.start = () => {
|
||||||
|
observer.observe(document, {subtree: true, childList: true});
|
||||||
|
};
|
||||||
|
tDocLoader.stop = () => {
|
||||||
observer.disconnect();
|
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);
|
.sort((a, b) => a.name < b.name ? -1 : a.name == b.name ? 0 : 1);
|
||||||
const shouldRenderAll = history.state && history.state.scrollY > innerHeight;
|
const shouldRenderAll = history.state && history.state.scrollY > innerHeight;
|
||||||
const renderBin = document.createDocumentFragment();
|
const renderBin = document.createDocumentFragment();
|
||||||
|
tDocLoader.stop();
|
||||||
renderStyles(0);
|
renderStyles(0);
|
||||||
// TODO: remember how many styles fit one page to display just that portion first next time
|
// TODO: remember how many styles fit one page to display just that portion first next time
|
||||||
function renderStyles(index) {
|
function renderStyles(index) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user