app/js/gallery.js in servel-0.29.0 vs app/js/gallery.js in servel-0.30.0
- old
+ new
@@ -1,11 +1,13 @@
"use strict";
var Gallery = (function() {
- var LAYOUT_MODES = ["fit-both", "fit-width", "clamp-width"];
+ var LAYOUT_MODES = ["fit-both", "fit-width", "clamp-width", "full-size"];
+ var $body;
var $gallery;
+ var $image;
var $video;
var $audio;
var currentIndex;
var layoutModeIndex = 0;
@@ -153,19 +155,42 @@
}
});
}
function layout() {
- var viewportHeight = document.documentElement.clientHeight + "px";
- $gallery.style.minHeight = viewportHeight;
+ var vw = document.documentElement.clientWidth;
+ var vh = document.documentElement.clientHeight;
+ var viewportOrientation = vw > vh ? "landscape" : "portrait";
+ $body.classList.remove("landscape", "portrait");
+ $body.classList.add(viewportOrientation);
+
+ $gallery.style.height = vh + "px";
+
+ var scrollerMaxHeight = viewportOrientation == "landscape" ? vh : vh - 75;
+
var layoutMode = LAYOUT_MODES[layoutModeIndex];
- var maxHeight = layoutMode == "fit-both" ? viewportHeight : "none";
- var maxWidth = layoutMode == "clamp-width" ? "1000px" : "100%";
- $("#image").style.maxWidth = maxWidth;
- $("#image").style.maxHeight = maxHeight;
+ if(layoutMode == "fit-both") {
+ var maxWidth = "100%";
+ var maxHeight = (scrollerMaxHeight + "px");
+ }
+ else if(layoutMode == "fit-width") {
+ var maxWidth = "100%";
+ var maxHeight = "none";
+ }
+ else if(layoutMode == "clamp-width") {
+ var maxWidth = "1000px";
+ var maxHeight = "none";
+ }
+ else if(layoutMode == "full-size") {
+ var maxWidth = "none";
+ var maxHeight = "none";
+ }
+
+ $image.style.maxWidth = maxWidth;
+ $image.style.maxHeight = maxHeight;
$video.style.maxWidth = maxWidth;
$video.style.maxHeight = maxHeight;
$audio.style.maxWidth = maxWidth;
$audio.style.maxHeight = maxHeight;
}
@@ -179,10 +204,12 @@
currentIndex = 0;
if(Entries.hasMedia()) render();
}
function init() {
+ $body = $("body");
$gallery = $("#gallery");
+ $image = $("#image");
$video = $("#video");
$audio = $("#audio");
onEntriesUpdate();
\ No newline at end of file