garand / sticky

jQuery Plugin for Sticky Objects
Other
3.3k stars 1.06k forks source link

Check if an element is sticky? #196

Open mizukimadness opened 8 years ago

mizukimadness commented 8 years ago

Hi!

I wonder if it's possible to check whether an element is sticky already, or not?

Here's my code at the moment:

function resize(){
        //Check window size
        if ( $(window).width() >= 1024) {
            // I want to do this here:
            // If (element) is sticky, i want to update the height : $('header.navigation').sticky('update');
            //Else: If there is no sticky I want to add it 
            $('header.navigation').sticky();

        } else {
            $('header.navigation').unstick();
        }
    }

    $(document).ready(function(){
        resize();
        $(window).resize(resize);
    });
clijiac commented 8 years ago

check if element wrapper .closest('.sticky-wrapper') has class is-sticky will be a solution I think.