Skip to content
Snippets Groups Projects
Commit 99349194 authored by alexisben's avatar alexisben
Browse files

debug tool for responsive img

parent ee715a83
No related branches found
No related tags found
No related merge requests found
......@@ -161,8 +161,39 @@
document.body.classList.toggle('full-width');
}
});
window.addEventListener('pointermove', e => {
document.querySelector('.d-cross').style.left = e.clientX + "px";
document.querySelector('.d-cross').style.top = e.clientY + "px";
});
document.querySelectorAll('img').forEach(img => {
img.addEventListener('click', e => {
if (e.altKey) {
e.preventDefault()
e.stopImmediatePropagation()
responsiveImageDebugOutput(img)
}
})
})
function responsiveImageDebugOutput(img) {
if (!img) {
throw new TypeError("Expected an image node. Got none.");
}
const listener = function () {
const dimensionWidth = img.naturalWidth * window.devicePixelRatio;
const dimensionHeight = img.naturalHeight * window.devicePixelRatio;
console.log(`
-------------------------
Device Pixel Ratio: ${window.devicePixelRatio}
Rendered size: ${img.width}x${img.height}
Intrinsic size: ${dimensionWidth}x${dimensionHeight}
Device Pixel Ratio: ${window.devicePixelRatio}
-------------------------
`);
};
if (img.complete) listener();
//img.addEventListener('load', listener);
}
</script>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment