mirror of
https://github.com/frainfreeze/the-monospace-web-pandoc
synced 2025-12-29 18:49:50 -08:00
13 lines
319 B
JavaScript
13 lines
319 B
JavaScript
// Set the ratio variable on each image.
|
|
document.querySelectorAll("img").forEach(img => {
|
|
function onLoaded() {
|
|
const ratio = img.naturalWidth / img.naturalHeight;
|
|
img.style.setProperty("--ratio", ratio);
|
|
}
|
|
if (img.loaded) {
|
|
onLoaded();
|
|
} else {
|
|
img.addEventListener("load", onLoaded);
|
|
}
|
|
});
|