Fix images being scaled incorrectly at low screen widths

fixes #2548
This commit is contained in:
Toks
2015-11-11 02:48:16 -05:00
parent e1800b3297
commit 250970a4b8
2 changed files with 15 additions and 17 deletions

View File

@@ -323,7 +323,7 @@
$notice.children().eq(0).hide(); $notice.children().eq(0).hide();
$notice.children().eq(1).show(); // Loading message $notice.children().eq(1).show(); // Loading message
Danbooru.Note.Box.scale_all(); Danbooru.Note.Box.scale_all();
$image.data("scale_factor", 1); $image.data("scale-factor", 1);
e.preventDefault(); e.preventDefault();
}); });
@@ -345,7 +345,7 @@
$notice.show(); $notice.show();
}); });
Danbooru.Note.Box.scale_all(); Danbooru.Note.Box.scale_all();
$image.data("scale_factor", 1); $image.data("scale-factor", 1);
e.preventDefault(); e.preventDefault();
} }
}); });
@@ -356,23 +356,25 @@
$("#image-resize-to-window-link").click(function(e) { $("#image-resize-to-window-link").click(function(e) {
var $img = $("#image"); var $img = $("#image");
if (($img.data("scale_factor") === 1) || ($img.data("scale_factor") === undefined)) { if (($img.data("scale-factor") === 1) || ($img.data("scale-factor") === undefined)) {
$img.data("original_width", $img.width()); if ($(window).width() > 660) {
$img.data("original_height", $img.height()); var client_width = $(window).width() - $("#sidebar").width() - 75;
var client_width = $(window).width() - $("#sidebar").width() - 75; } else {
var client_width = $(window).width() - 30;
}
var client_height = $(window).height(); var client_height = $(window).height();
if ($img.width() > client_width) { if ($img.width() > client_width) {
var ratio = client_width / $img.width(); var ratio = client_width / $img.data("original-width");
$img.data("scale_factor", ratio); $img.data("scale-factor", ratio);
$img.css("width", $img.data("original_width") * ratio); $img.css("width", $img.data("original-width") * ratio);
$img.css("height", $img.data("original_height") * ratio); $img.css("height", $img.data("original-height") * ratio);
Danbooru.Post.resize_ugoira_controls(); Danbooru.Post.resize_ugoira_controls();
} }
} else { } else {
$img.data("scale_factor", 1); $img.data("scale-factor", 1);
$img.width($img.data("original_width")); $img.width($img.data("original-width"));
$img.height($img.data("original_height")); $img.height($img.data("original-height"));
Danbooru.Post.resize_ugoira_controls(); Danbooru.Post.resize_ugoira_controls();
} }

View File

@@ -175,10 +175,6 @@
display: block; display: block;
} }
#image {
max-width: 400px;
}
body { body {
width: 100%; width: 100%;
} }