From e4b5e896730cfc9f0d7447a3dbe40e13f331ef5b Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 24 Apr 2011 23:31:49 -0700 Subject: [PATCH] stop using 100% width; closes #12 --- 4chan_x.js | 5 +++-- script.coffee | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index ded18016e..c8f463ed9 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1936,8 +1936,9 @@ case 'full': return img.removeAttribute('style'); case 'fit width': - if (iw > cw) { - img.style.width = '100%'; + ratio = cw / iw; + if (ratio < 1) { + img.style.width = Math.floor(ratio * iw); return img.style.margin = '0px'; } break; diff --git a/script.coffee b/script.coffee index b85ed1057..f931b77e2 100644 --- a/script.coffee +++ b/script.coffee @@ -1472,13 +1472,14 @@ imgExpand = when 'full' img.removeAttribute 'style' when 'fit width' - if iw > cw - img.style.width = '100%' + ratio = cw/iw + if ratio < 1 + # y'know, this width is constant between resizes + img.style.width = Math.floor ratio * iw img.style.margin = '0px' when 'fit screen' ratio = Math.min cw/iw, ch/ih if ratio < 1 - #XXX maybe needs + 'px' ? img.style.width = Math.floor ratio * iw img.style.margin = '0px'