Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to turn off and hide main/top window scrollbars? #26

Open
bandzgla opened this issue Jun 29, 2012 · 1 comment
Open

How to turn off and hide main/top window scrollbars? #26

bandzgla opened this issue Jun 29, 2012 · 1 comment

Comments

@bandzgla
Copy link

Like in topic, when im using shadowbox with iframe it have scrollbars inside and in main window there is a scrollbar too, how can I turn it off, so only those from iframe would be working when its opened?

greetings!

@karfau
Copy link

karfau commented Apr 28, 2013

with inspiration from there:
http://stackoverflow.com/questions/8701754/just-disable-scroll-not-hide-it
http://stackoverflow.com/questions/9280258/prevent-body-scrolling-but-allow-overlay-scrolling

I came to this snippet that worked for me:

    Shadowbox.init({ skipSetup: true });

    window.onload = function() {
        var $body = $('body'), $html = $('html');
        var scrollTop = 0;

        Shadowbox.setup("your selector",{
            onOpen:function(){
                if (window.innerHeight < window.outerHeight) {
                    scrollTop = ($html.scrollTop()) ? $html.scrollTop() : $body.scrollTop();
//                    $html.addClass('noscroll').css('top',-scrollTop);
                    $body.addClass('noscroll').css('top',-scrollTop);
                }
            },
            onClose:function(){
                $body.removeClass('noscroll').css('top','auto');
                $('html,body').scrollTop(scrollTop);
            }
        });
    };

(this is using the jquery-adapter,css-selector and delayed setup as documented)

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

No branches or pull requests

2 participants