1 (edited by dirk 2017-05-31 11:51:58)

Topic: Gallery width whitespace

Hi,

please have a look at my website

At the bottom of the page there is a Juicebox gallery. Screen mode is auto.

It displays 100% width on desktop computers as it should do. Auto screen mode works fine on smartphones.

On iPads however the gallery has whitespace on left and right sides if held in landscape mode. If held in portrait mode everything is fine again and wihtespace disappears.

It seems that the script calculates the available room based on portrait mode but doesn´t adapt if the device is being turned to landscape mode.

This is the beginning of the config.xml:

<?xml version="1.0" encoding="UTF-8"?>

<juiceboxgallery 

    resizeOnImport="false"
    useFullscreenExpand="true"
    maxImageWidth="1200"
    maxImageHeight="900"
    textColor="rgba(0,0,0,1)"
    buttonBarBackColor="rgba(51,51,51,.3)"
    topBackColor="rgba(255,255,255,0)"
    captionBackColor="rgba(255,255,255,.0)"
    backgroundColor="rgba(51,51,51,1)"
    autoPlayThumbs="false"
    showSmallThumbsOnLoad="false"
    showSmallThumbsButton="false"
    showNavButtons="true"
    showAutoPlayButton="true"
    captionPosition="BELOW_IMAGE"
    captionHAlign="LEFT"
    captionBackTopColor="rgba(255,255,255,0)"
    textShadowColor="rgba(102,102,102,0.4)"
    maxCaptionHeight="100"
    screenMode="AUTO"
    buttonBarPosition="OVERLAY_IMAGE"
    buttonBarIconSize="15"
    thumbsVAlign="TOP"
    showOpenButton="false"

>

Is it possible to fix that behaviour?

Thanks and kind regards

Dirk

Re: Gallery width whitespace

Unfortunately, I don't have an iPad on which to test but your gallery's Splash Page (in your embedding web page) and the gallery itself both look OK on my iPod Touch. The Splash Page resizes correctly when changing orientation and, when the gallery has been expanded from the Splash Page, the images are displayed as large as possible within the gallery's image area (no matter what orientation the device is in).

Here are a couple of things I notice which might point you in the right direction.

(1) Your embedding page does not seem to be responsive in desktop browsers.
If the browser window is made more narrow, then the content on your web page does not adapt to the new width. The content is simply truncated (beyond the right-hand side of the browser window). This might be contributing to your problem in browser viewports of a certain width. Rotating your iPad might have a similar effect to changing the width of a desktop browser window (where your embedding page no longer fits the browser viewport).

(2) You have given your gallery dimensions of 100% x 100%. This might be perfectly OK but please check your gallery's parent container to see what dimensions have been assigned to it via CSS. A gallery height of 100% means that the gallery's actual height will be 100% of the height of its parent container. If the gallery's parent container has not been assigned a height via CSS, then Juicebox may not be able to determine what the gallery's actual height should be 100% of and this might cause your gallery to be displayed at unexpected dimensions.
Try giving your gallery a fixed pixel height (and try a few different values) instead of a percentage (at least for testing purposes). A gallery with a greater height will have a larger image area and this may allow the image to be displayed larger (depending on aspect ratios) with less space to the left and right.
Also, as your embedding page seems to be based on a fixed width, you might like to try giving your gallery a fixed width, too (to match that of your page).

If you continue to experience difficulties, please let me know the following:
(1) Does the problem happen only within the embedding page or also when the gallery has been expanded?
(2) What version of iPad do you have?
(3) What version of iOS do you run on your iPad?
(4) What browser (or browsers) do you see the problem in (Mobile Chrome, Mobile Firefox, Mobile Safari)?

Also, if possible, please provide screenshots so that I can see what you are seeing (as I do not have an iPad and cannot see your problem). You can attach images to a forum post if you like or upload them elsewhere and provide links.

Hopefully, once I'm able to see the problem (at least in screenshots), I should have a better idea of what might be causing it and might be able to propose a solution.
Thank you.

Re: Gallery width whitespace

Hi,
thx for your support.

I found out that, if I click away thumbnails, gallery image is resized and gets larger. If I display thumbnails again gallery image shrinks.

Is it possible to overwrite this behaviour?

Kind regards

Dirk

Re: Gallery width whitespace

The gallery's dimensions are determined by the galleryWidth and galleryHeight options (set in the embedding code) and the gallery's size remains constant (unless percentage dimensions are used and the size of the browser window changes). No controls within the gallery will affect the gallery's size.

When you choose to show thumbnails, then space needs to be made available for them so the size of the main image decreases.
When you chose to hide the thumbnails, then extra space within the gallery becomes available and the size of the main image increases to take advantage of this (to display the main image as large as possible within the gallery).

It is not possible to not change the size of the main image when the thumbnails are toggled on or off (you'd have a blank space where the thumbnails would be when they are not shown).

You could, however, choose to always use the Small Screen Mode version of the gallery, where thumbnails and main images are displayed on separate pages (rather that sharing the gallery space together on the same page), by setting screenMode="SMALL" (in JuiceboxBuilder-Pro's 'Customize -> General' section).

If you choose to continue to use screenMode="AUTO", then you can disable the thumbnails completely when the gallery is displayed in Large Screen Mode by setting showThumbsOnLoad="FALSE" ('Customize -> Thumbnails') and showThumbsButton="FALSE" ('Customize -> Lite'). Alternatively, you can always have the thumbnails displayed (and prevent them from being hidden) by setting showThumbsOnLoad="TRUE" and showThumbsButton="FALSE".

If you really want to have the size of your gallery change when the thumbnails are toggled on or off, then you could try something like the following which takes advantage of several Juicebox-Pro API methods.
Create a sample gallery in JuiceboxBuilder-Pro and use the following code as the gallery's 'index.html' file.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" id="jb-viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
        <style type="text/css">
            body {
                margin: 0px;
            }
        </style>
        <script type="text/javascript" src="jbcore/juicebox.js"></script>
        <script type="text/javascript">
            var galleryWidthHideThumbnails = 600;
            var galleryWidthShowThumbnails = 600;
            var galleryHeightHideThumbnails = 400;
            var galleryHeightShowThumbnails = 505;
            var jb = new juicebox({
                containerId: "juicebox-container",
                galleryHeight: galleryHeightShowThumbnails,
                galleryWidth: galleryWidthShowThumbnails,
                showThumbsButton: "TRUE",
                showThumbsOnLoad: "TRUE"
            });
            jb.onInitComplete = function() {
                if (jb.getScreenMode() === "LARGE") {
                    jb.onShowThumbs = function(showing) {
                        window.setTimeout(function() {
                            var width = showing ? galleryWidthShowThumbnails : galleryWidthHideThumbnails;
                            var height = showing ? galleryHeightShowThumbnails : galleryHeightHideThumbnails;
                            jb.setGallerySize(width, height);
                        }, 500);
                    }
                }
            };
        </script>
        <title>Test</title>
    </head>
    <body>
        <div id="juicebox-container"></div>
    </body>
</html>

You can change the gallery dimensions as you like.

Please note that this is not an ideal solution. Juicebox was not designed with this in mind and a short delay is required to ensure that the gallery is not resized until after the thumbnails are toggled on or off. This ensures that the thumbnails are not temporarily displayed on top of the main image (which looks untidy) but has the side effect that the main image is temporarily resized when the thumbnails are shown (slightly less untidy).

As this is not something that Juicebox was designed to do, I would recommend using the available configuration options to reach a compromise although you are certainly free to use and modify the code I provided if you like (although please be aware that trying to do something that Juicebox was not designed to do can often be fraught with difficulties and unforeseen problems might need to be tackled along the way).

I hope these notes help.

5 (edited by dirk 2017-06-04 09:37:06)

Re: Gallery width whitespace

Hi,

I think I was able to solve the problem.

I assigned a fixed height of 950 px which doesn´t sound well with regard to responsive design but works in addition with smart screen mode.

Thanks again

Dirk

Re: Gallery width whitespace

Actually, a fixed height gallery often works very well in web pages that have a lot of content and scroll vertically (and are not designed to fit all content within the browser window without any scrolling). The gallery can still be responsive in the horizontal dimension (as long as the gallery's width is defined as a percentage and your web page's layout is, itself, responsive).

Re: Gallery width whitespace

You are right. I mixed things up regarding responsive design. Thx for clarification.

Just another question. On smartphones the fixed height of 950px is bit too much. Nothing particularly bad, but I would prefer it to display smaller in height.

Is that possible: 950px height on larger devices, less on small screens.

Thanks.

Dirk

Re: Gallery width whitespace

Is that possible: 950px height on larger devices, less on small screens.

Juicebox uses only one galleryHeight value for both Small Screen Mode and Large Screen Mode so trying to use a different value for each screen mode is not going to be easy.
However, there are a few things you could try.

(1) Load the gallery with dimensions for Large Screen Mode, check the Screen Mode being used (via the Juicebox-Pro API getScreenMode() method) and resize the gallery with appropriate dimensions (via the setGallerySize() method) if Small Screen Mode is being used. However, the setGallerySize() method accepts only fixed pixel values for both the width and height so maintaining a width of 100% would not be possible using this method.
If you wanted to try this, though, you could use embedding code such as:

<script>
    var galleryWidthLargeScreenMode = '1000';
    var galleryWidthSmallScreenMode = '1000';
    var galleryHeightLargeScreenMode = '950';
    var galleryHeightSmallScreenMode = '650';
    var jb = new juicebox({
        containerId: "juicebox-container",
        galleryWidth: galleryWidthLargeScreenMode,
        galleryHeight: galleryHeightLargeScreenMode,
        screenMode: "AUTO"
    });
    jb.onInitComplete = function() {
        var screenMode = jb.getScreenMode();
        if (screenMode === 'SMALL') {
            jb.setGallerySize(galleryWidthSmallScreenMode, galleryHeightSmallScreenMode);
        }
    };
</script>

(2) Use your own custom JavaScript function to check if a mobile device is being used to view the gallery and then set a gallery height accordingly. It is unlikely that your JavaScript check will exactly match up with Juicebox's own internal test for whether to use Small or Large Screen Mode (I do not know the exact logic that Juicebox uses) but it might be good enough for most situations.
You could maybe use a galleryHeight entry in your embedding code such as:

galleryHeight: /Android|BlackBerry|iPad|iPhone|iPod|Nexus|webOS/i.test(navigator.userAgent) ? '650' : '950',

(3) Load the gallery with dimensions for Large Screen Mode, check the Screen Mode being used (via the Juicebox-Pro API getScreenMode() method) and reload the gallery with appropriate dimensions if Small Screen Mode is being used. This method will allow you to maintain a gallery width of 100% (unlike #1 above) and your choice of heights will always match up with the Screen Mode being used (unlike #2 above) but it would be the most complicated of the 3 suggestions to implement and you'd probably want to hide things using CSS until the gallery has been loaded with the correct dimensions (and you'd also need a tracking variable to ensure that the reloading of the gallery does not happen repeatedly).
To see this in action, create a test gallery with JuiceboxBuilder-Pro and use the following code as the gallery's 'index.html' file.

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" id="jb-viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" />
        <style type="text/css">
            body {
                margin: 0px;
            }
            #juicebox-container {
                display: none;
            }
        </style>
        <script type="text/javascript" src="jbcore/juicebox.js"></script>
        <script type="text/javascript">
            var counter = 0;
            var galleryWidthLargeScreenMode = '100%';
            var galleryWidthSmallScreenMode = '100%';
            var galleryHeightLargeScreenMode = '950';
            var galleryHeightSmallScreenMode = '650';
            var jb;
            function loadGallery(width, height) {
                jb = new juicebox({
                    containerId: "juicebox-container",
                    galleryWidth: width,
                    galleryHeight: height,
                    screenMode: "AUTO"
                });
                counter++;
            }
            loadGallery(galleryWidthLargeScreenMode, galleryHeightLargeScreenMode);
            jb.onInitComplete = function() {
                var screenMode = jb.getScreenMode();
                if (counter === 1 && screenMode === 'SMALL') {
                    loadGallery(galleryWidthSmallScreenMode, galleryHeightSmallScreenMode);
                }
                if ((counter === 1 && screenMode === 'LARGE') || (counter === 2 && screenMode === 'SMALL')) {
                    $('#juicebox-container').show();
                }
            };
        </script>
        <title>Test</title>
    </head>
    <body>
        <div id="juicebox-container"></div>
    </body>
</html>

#2 would certainly be the easiest to implement but you might like to try incorporating the code from #3 into your web page.

I hope this helps.

Re: Gallery width whitespace

Thanks, Steven.

#2 works just fine.

Excellent support (even if it wouldn´t have worked ;-))

Re: Gallery width whitespace

You're welcome!
I'm glad you've been able to implement one of my suggestions into your gallery.
Thank you for letting me know.