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
when 'full'
image.removeAttribute 'width'
image.removeAttribute 'style'
return
when 'fit width'
ratio = cw/iw
if iw > cw
image.style.width = '100%'
image.style.margin = '0px'
when 'fit screen'
ratio = Math.min cw/iw, ch/ih
if ratio < 1
image.width = Math.floor ratio * iw
if ratio < 1
image.style.width = Math.floor ratio * iw
image.style.margin = '0px'
imageThumb = (thumb) ->
thumb.className = ''

View File

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