Topic: Resizable in both Height and Width
Hi,
I use RapidWeaver (based on templates) to build my website. I would like my embedded JB gallery to show in the maximum available space – width AND height – and to be resizable.
Having to deal with both vertical (header-s and footer) and horizontal (sidebar) elements I tried to combine the two Javascript examples I found in https://www.juicebox.net/demos/support/ … u/gallery1 and https://www.juicebox.net/demos/support/ … u/gallery1
I ended up with the JS below. It works almost perfectly, except when the window's height is reduced where you get a grey line/rectangle below the gallery (which is also true on an iPhone after you tap the screen the toolbar disappears).
https://www.ouvertlanuit.fr/test/juicebox-incluse/
I'm quite new to Javascript and any help to fine tune mine will be very welcome.
Regards
Gilles
var jbGallery;
function setContainerHeight() {
var winHeight, headerWrapperHeight, footerHeight;
winHeight = window.innerHeight ? window.innerHeight : $(window).height();
headerWrapperHeight = $('#headerWrapper').outerHeight();
footerHeight = $('#footer').outerHeight();
var newH = parseInt(winHeight) - parseInt(headerWrapperHeight) - parseInt(footerHeight) + 8;
var winWidth, sideWidth;
winWidth = window.innerWidth ? window.innerWidth : $(window).width();
sideWidth = $('#aside').outerWidth() + 1;
var newW = parseInt(winWidth) - parseInt(sideWidth);
$('#stacks_in_2_page28').height(newH);
return newH;
}
function doLayout() {
if(!jbGallery){
setContainerHeight();
return;
}
window.setTimeout(function(){
var newH = setContainerHeight();
// var newW = setContainerHeight();
jbGallery.setGallerySize(newW, newH);
}, 200);
}
$(document).ready(function () {
doLayout();
$(window).bind('resize', doLayout);
jbGallery = new juicebox({
containerid : 'juicebox-container'
});
});