From c9f6567809ceb4bc60f54e7f052fd049ef0b913e Mon Sep 17 00:00:00 2001 From: Peter Coles Date: Tue, 13 Feb 2018 15:53:14 -0500 Subject: [PATCH] fit image to maxWidth 100% When you open image-diff in a new window it defaults to max-width 100%. This feels more natural for looking at large images. Clicking on the image will toggle fitting to the page width or natural size. --- demoassets/main.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/demoassets/main.js b/demoassets/main.js index db8e854..7e56e7b 100644 --- a/demoassets/main.js +++ b/demoassets/main.js @@ -72,6 +72,10 @@ $(function(){ var img = w.document.createElement("img"); img.src = diffImage.src; img.alt = "image diff"; + img.style.maxWidth = "100%"; + img.addEventListener("click", function() { + this.style.maxWidth = this.style.maxWidth === "100%" ? "" : "100%"; + }); body.appendChild(img); });