diff --git a/dist/main.js b/dist/main.js index be5a4ea..f1fa527 100644 Binary files a/dist/main.js and b/dist/main.js differ diff --git a/dist/view.js b/dist/view.js index 56fd4d9..c48dc1b 100644 Binary files a/dist/view.js and b/dist/view.js differ diff --git a/src/scripts/view/main.js b/src/scripts/view/main.js index 644d6d1..bb44d33 100644 --- a/src/scripts/view/main.js +++ b/src/scripts/view/main.js @@ -39,32 +39,50 @@ key = function(e) { var code = (e.keyCode ? e.keyCode : e.which); - if (code===27&&visibleInfobox()) { + if (code===27) { hideInfobox(); e.preventDefault(); } } -visibleInfobox = function() { +getPhotoSize = function(photo) { - if (parseInt(infobox.css('right').replace('px', ''))<0) return false; - else return true; + // Size can be 'big', 'medium' or 'small' + // Default is big + // Small is centered in the middle of the screen + var size = 'big', + scaled = false, + hasMedium = photo.medium!=='', + pixelRatio = window.devicePixelRatio, + view = { + width: $(window).width()-60, + height: $(window).height()-100 + }; -} + // Detect if the photo will be shown scaled, + // because the screen size is smaller than the photo + if (photo.width>view.width|| + photo.width>view.height) scaled = true; -isPhotoSmall = function(photo) { + // Calculate pixel ratio of screen + if (pixelRatio!==undefined&&pixelRatio>1) { + view.width = view.width * pixelRatio; + view.height = view.height * pixelRatio; + } - var size = { - width: false, - height: false - }; + // Medium available and + // Medium still bigger than screen + if (hasMedium===true&& + (1920>view.width&&1080>view.height)) size = 'medium'; - if (photo.width<$(window).width()-60) size.width = true; - if (photo.height<$(window).height()-100) size.height = true; + // Photo not scaled + // Photo smaller then screen + if (scaled===false&& + (photo.width"); - else imageview.html("
"); + if (size==='big') imageview.html("
"); + else if (size==='medium') imageview.html("
"); + else imageview.html("
"); imageview .removeClass('fadeOut')