Browse Source

Improved size detection #67

Tobias Reich 9 years ago
parent
commit
2421db7469
2 changed files with 8 additions and 2 deletions
  1. 0 0
      dist/main.js
  2. 8 2
      src/scripts/photo.js

File diff suppressed because it is too large
+ 0 - 0
dist/main.js


+ 8 - 2
src/scripts/photo.js

@@ -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';
 

Some files were not shown because too many files changed in this diff