Skip to content

Commit 9a0ec47

Browse files
committed
Fix preview wrapper size when $(document).height() > $(window).height()
1 parent 9634a3a commit 9a0ec47

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

app.css

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ a, a:hover {
5858
right: 10%;
5959
bottom: 10%;
6060
left: 10%;
61+
min-width: 10%;
6162
background: rgba(0, 0, 0, 0.5);;
6263
transition: width 200ms, height 200ms, left 200ms;
6364
text-align: center;

app.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ var app = function(){
100100
$(".file-view-img").css('padding-top', '0');
101101
$(".file-view-img").attr('src', filepath);
102102
$(".file-view-img").fadeIn();
103-
var scale_width = 0.8 * $(document).width() / img.width;
104-
var scale_height = 0.8 * $(document).height() / img.height;
103+
var scale_width = 0.8 * $(window).width() / img.width;
104+
var scale_height = 0.8 * $(window).height() / img.height;
105105
var imgWidth = img.width * Math.min(scale_width, scale_height);
106+
var imgHeight = img.height * Math.min(scale_width, scale_height);
106107
$(".file-view-wrapper").css('left', ($(document).width() - imgWidth) / 2);
107108
$(".file-view-wrapper").css('width', imgWidth);
109+
$(".file-view-wrapper").css('height', imgHeight);
108110
$(".file-view-prev").css('display', 'block');
109111
$(".file-view-next").css('display', 'block');
110112
};

0 commit comments

Comments
 (0)