Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Tweak calculations to avoid scrollbar from showing on small screens
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Jun 27, 2016
1 parent b965992 commit d605014
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/featherlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,13 @@
/* Reset apparent image size first so container grows */
this.$content.css('width', '').css('height', '');
/* Calculate the worst ratio so that dimensions fit */
/* Note: -1 to avoid rounding errors */
var ratio = Math.max(
w / parseInt(this.$content.parent().css('width'),10),
h / parseInt(this.$content.parent().css('height'),10));
w / (parseInt(this.$content.parent().css('width'),10)-1),
h / (parseInt(this.$content.parent().css('height'),10)-1));
/* Resize content */
if (ratio > 1) {
ratio = h / Math.floor(h / ratio); /* Round ratio down so height calc works */
this.$content.css('width', '' + w / ratio + 'px').css('height', '' + h / ratio + 'px');
}
}
Expand Down

0 comments on commit d605014

Please sign in to comment.