WeCodePixels / theia-sticky-sidebar

Glues your website's sidebars, making them permanently visible while scrolling.
MIT License
569 stars 209 forks source link

destroy sticky sidebar #48

Closed Fanni-Portier closed 7 years ago

Fanni-Portier commented 7 years ago

Hi!

I want the sticky sidebar only on a viewport size 900 and bigger. How can I remove all the theia things in the code when I resize the window after loading the sticky sidebar? It causes problems on smaller screens.

I used this code: ` $(document).ready(function() {

        var $window = $(window);

        function stickySidebar() {
            if ( $(window).width() >= 901 ) {
                $(document).ready(function() {
                    $('.sidebar')
                        .theiaStickySidebar();
                });
            }
        }

        $(window).scroll(function() {
           stickySidebar();
        });

        $(window).resize(function() {
           stickySidebar();
        });

        $(document).ready(function() {
            stickySidebar();
        });
});

`

liviucmg commented 7 years ago

There is a minWidth option you can use. The only code you need is this:

$(document).ready(function() {
    $('.sidebar').theiaStickySidebar({
        minWidth: 900
    });
});

Otherwise there isn't a way to completely "unload" the sticky sidebar.

Fanni-Portier commented 7 years ago

Oh boy!!! That easy! Thanks :)