mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Added new fit mode for both dimensions
This commit is contained in:
@ -38,6 +38,25 @@ App.Presenters.PostContentPresenter = function(
|
||||
var containerWidth = $wrapper.parent().outerWidth() - 10;
|
||||
|
||||
return {
|
||||
'fit-both': function(allowUpscale) {
|
||||
var width = containerWidth;
|
||||
var height = containerWidth / ratio;
|
||||
if (height > containerHeight) {
|
||||
width = containerHeight * ratio;
|
||||
height = containerHeight;
|
||||
}
|
||||
if (!allowUpscale) {
|
||||
if (width > originalWidth) {
|
||||
width = originalWidth;
|
||||
height = originalWidth / ratio;
|
||||
}
|
||||
if (height > originalHeight) {
|
||||
width = originalHeight * ratio;
|
||||
height = originalHeight;
|
||||
}
|
||||
}
|
||||
$wrapper.css({maxWidth: width + 'px', width: ''});
|
||||
},
|
||||
'fit-height': function(allowUpscale) {
|
||||
var width = containerHeight * ratio;
|
||||
if (width > originalWidth && !allowUpscale) {
|
||||
|
Reference in New Issue
Block a user