get rid of horizontal scrollbars for fit width
This commit is contained in:
parent
292c3e1e6c
commit
c68b76721c
@ -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 = ''
|
||||||
|
|||||||
15
4chan_x.js
15
4chan_x.js
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user