mirror of
https://github.com/frainfreeze/the-monospace-web-pandoc
synced 2025-12-30 02:59:50 -08:00
support images
This commit is contained in:
12
index.js
Normal file
12
index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user