Improved size detection #67

This commit is contained in:
Tobias Reich 2014-10-18 16:30:25 +02:00
parent 280e42afd6
commit 2421db7469
2 changed files with 8 additions and 2 deletions

BIN
dist/main.js vendored

Binary file not shown.

View File

@ -549,6 +549,7 @@ photo = {
// Default is big
// Small is centered in the middle of the screen
var size = 'big',
scaled = false,
hasMedium = photo.json.medium!=="",
pixelRatio = window.devicePixelRatio,
view = {
@ -556,6 +557,11 @@ photo = {
height: $(window).height()-100
};
// Detect if the photo will be shown scaled,
// because the screen size is smaller than the photo
if (photo.json.width>view.width||
photo.json.width>view.height) scaled = true;
// Calculate pixel ratio of screen
if (pixelRatio!==undefined&&pixelRatio>1) {
view.width = view.width * pixelRatio;
@ -567,9 +573,9 @@ photo = {
if (hasMedium===true&&
(1920>view.width&&1080>view.height)) size = 'medium';
// Medium not available and
// Photo not scaled
// Photo smaller then screen
if (hasMedium===false&&
if (scaled===false&&
(photo.json.width<view.width&&
photo.json.width<view.height)) size = 'small';