Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

restore height on viewport resize when using relative "vh" measurement #84

Open
camedia opened this issue Mar 3, 2016 · 2 comments
Open

Comments

@camedia
Copy link

camedia commented Mar 3, 2016

greetings,

first, thanks for the brilliant and beautiful plugin. loving it. anyways, i noticed something while wrapping up a project, that could probably be marked as an enhancement more than a bug.

when using the relative viewport-based measurement, vh, the height of the scrollbar container reacts beautifully and shrinks as the viewport is resized. but when the viewport is opened back up again, vertically, the scrollable container stays stuck at its last/shortest height.

i threw a pen together using everything almost verbatim from the basic demo. i only converted the max-height to a vh value.

my hope is to use this plugin to pull off the responsive left nav that's on google's developers site (without having to reverse engineer or recreate anything from scratch). that junk is so sexy. i'm basically all the way there except this last detail.

cheers,
/chris

@gromo
Copy link
Owner

gromo commented Mar 3, 2016

Hello Chris.

I will try to look at this issue in next few days. If I won't answer in a week, please, remind me by updating this issue. Thanks.

@gromo
Copy link
Owner

gromo commented Mar 6, 2016

I see the problem. It cannot be fixed fast, but for now you can change the handler of window resize from:

$(window).resize(function () {
    var forceUpdate = false;
    if (browser.scroll && (browser.scroll.height || browser.scroll.width)) {
        var scroll = getBrowserScrollSize();
        if (scroll.height !== browser.scroll.height || scroll.width !== browser.scroll.width) {
            browser.scroll = scroll;
            forceUpdate = true; // handle page zoom
        }
    }
    updateScrollbars(forceUpdate);
});

to always re-initialize scrollbar when window is resized:

$(window).resize(function () {
    updateScrollbars(true);
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants