get rid of horizontal scrollbars for fit width

This commit is contained in:
James Campos 2011-01-18 01:41:13 -08:00
parent 292c3e1e6c
commit c68b76721c
2 changed files with 16 additions and 10 deletions

View File

@ -429,14 +429,17 @@ imageResize = (cw, ch, imageType, image) ->
switch imageType switch imageType
when 'full' when 'full'
image.removeAttribute 'width' image.removeAttribute 'style'
return return
when 'fit width' when 'fit width'
ratio = cw/iw if iw > cw
image.style.width = '100%'
image.style.margin = '0px'
when 'fit screen' when 'fit screen'
ratio = Math.min cw/iw, ch/ih ratio = Math.min cw/iw, ch/ih
if ratio < 1 if ratio < 1
image.width = Math.floor ratio * iw image.style.width = Math.floor ratio * iw
image.style.margin = '0px'
imageThumb = (thumb) -> imageThumb = (thumb) ->
thumb.className = '' thumb.className = ''

View File

@ -615,16 +615,19 @@
ih = Number(ih); ih = Number(ih);
switch (imageType) { switch (imageType) {
case 'full': case 'full':
image.removeAttribute('width'); image.removeAttribute('style');
return; return;
case 'fit width': case 'fit width':
ratio = cw / iw; if (iw > cw) {
break; image.style.width = '100%';
return image.style.margin = '0px';
}
case 'fit screen': case 'fit screen':
ratio = Math.min(cw / iw, ch / ih); ratio = Math.min(cw / iw, ch / ih);
} if (ratio < 1) {
if (ratio < 1) { image.style.width = Math.floor(ratio * iw);
return image.width = Math.floor(ratio * iw); return image.style.margin = '0px';
}
} }
}; };
imageThumb = function(thumb) { imageThumb = function(thumb) {