Improved size detection #67
This commit is contained in:
parent
280e42afd6
commit
2421db7469
BIN
dist/main.js
vendored
BIN
dist/main.js
vendored
Binary file not shown.
@ -549,6 +549,7 @@ photo = {
|
|||||||
// Default is big
|
// Default is big
|
||||||
// Small is centered in the middle of the screen
|
// Small is centered in the middle of the screen
|
||||||
var size = 'big',
|
var size = 'big',
|
||||||
|
scaled = false,
|
||||||
hasMedium = photo.json.medium!=="",
|
hasMedium = photo.json.medium!=="",
|
||||||
pixelRatio = window.devicePixelRatio,
|
pixelRatio = window.devicePixelRatio,
|
||||||
view = {
|
view = {
|
||||||
@ -556,6 +557,11 @@ photo = {
|
|||||||
height: $(window).height()-100
|
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
|
// Calculate pixel ratio of screen
|
||||||
if (pixelRatio!==undefined&&pixelRatio>1) {
|
if (pixelRatio!==undefined&&pixelRatio>1) {
|
||||||
view.width = view.width * pixelRatio;
|
view.width = view.width * pixelRatio;
|
||||||
@ -567,9 +573,9 @@ photo = {
|
|||||||
if (hasMedium===true&&
|
if (hasMedium===true&&
|
||||||
(1920>view.width&&1080>view.height)) size = 'medium';
|
(1920>view.width&&1080>view.height)) size = 'medium';
|
||||||
|
|
||||||
// Medium not available and
|
// Photo not scaled
|
||||||
// Photo smaller then screen
|
// Photo smaller then screen
|
||||||
if (hasMedium===false&&
|
if (scaled===false&&
|
||||||
(photo.json.width<view.width&&
|
(photo.json.width<view.width&&
|
||||||
photo.json.width<view.height)) size = 'small';
|
photo.json.width<view.height)) size = 'small';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user