mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Add function to automatically add/rm the coarse class
Based on viewport height. Automatically adjusted onresize.
This commit is contained in:
@@ -15,5 +15,26 @@ window.onload = function() {
|
|||||||
|
|
||||||
container.appendChild(heading);
|
container.appendChild(heading);
|
||||||
container.appendChild(toc);
|
container.appendChild(toc);
|
||||||
|
|
||||||
|
resize_toc(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resize_toc(container) {
|
||||||
|
var containerHeight = container.clientHeight;
|
||||||
|
|
||||||
|
var resize = function() {
|
||||||
|
if (containerHeight > document.documentElement.clientHeight - 100) {
|
||||||
|
container.classList.add('coarse');
|
||||||
|
} else {
|
||||||
|
container.classList.remove('coarse');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
resize();
|
||||||
|
|
||||||
|
var resizeId;
|
||||||
|
window.onresize = function() {
|
||||||
|
clearTimeout(resizeId);
|
||||||
|
resizeId = setTimeout(resize, 300);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user