Skip to content

Instantly share code, notes, and snippets.

@rbk
Created September 25, 2014 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rbk/03c99edbffc27c7d9e1d to your computer and use it in GitHub Desktop.
Save rbk/03c99edbffc27c7d9e1d to your computer and use it in GitHub Desktop.
Ugly jquery
$(document).ready(function(){
$(window).bind("scroll",function(e){
if($(document).width() > 551) {
if($(document).height() > 1000) {
if($(document).scrollTop() > 100) {
$( ".site-branding" ).addClass( "site-branding-response" );
$( ".site-title" ).addClass( "site-title-response" );
$( ".menu-item" ).addClass( "menu-item-response" );
$( ".company_contact_info" ).addClass( "company_contact_info_response" );
} else {
$( ".site-branding" ).removeClass( "site-branding-response" );
$( ".site-title" ).removeClass( "site-title-response" );
$( ".menu-item" ).removeClass( "menu-item-response" );
$( ".company_contact_info" ).removeClass( "company_contact_info_response" );
}
} else {
$( ".site-branding" ).removeClass( "site-branding-response" );
$( ".site-title" ).removeClass( "site-title-response" );
$( ".menu-item" ).removeClass( "menu-item-response" );
$( ".company_contact_info" ).removeClass( "company_contact_info_response" );
}
} else {
$( ".site-branding" ).removeClass( "site-branding-response" );
$( ".site-title" ).removeClass( "site-title-response" );
$( ".menu-item" ).removeClass( "menu-item-response" );
$( ".company_contact_info" ).removeClass( "company_contact_info_response" );
}
});
$(window).bind("scroll",function(e){
if($(document).width() > 551) {
if($(document).scrollTop() > 100) {
$( ".site-branding" ).removeClass( "site-branding-response" );
$( ".site-title" ).removeClass( "site-title-response" );
$( ".menu-item" ).removeClass( "menu-item-response" );
$( ".company_contact_info" ).removeClass( "company_contact_info_response" );
$( ".site-branding" ).addClass( "site-branding-response" );
$( ".site-title" ).addClass( "site-title-response" );
$( ".menu-item" ).addClass( "menu-item-response" );
$( ".company_contact_info" ).addClass( "company_contact_info_response" );
}
}
});
});
@terrillo
Copy link

$(document).ready(function(){

function byebye() {
    $( ".site-branding" ).removeClass( "site-branding-response" );
    $( ".site-title" ).removeClass( "site-title-response" );
    $( ".menu-item" ).removeClass( "menu-item-response" );
    $( ".company_contact_info" ).removeClass( "company_contact_info_response" );
}

function yesyes() {
    $( ".site-branding" ).addClass( "site-branding-response" );
    $( ".site-title" ).addClass( "site-title-response" );
    $( ".menu-item" ).addClass( "menu-item-response" );
    $( ".company_contact_info" ).addClass( "company_contact_info_response" );
}

$(window).bind("scroll",function(e){
    if($(document).width() > 551) {
        if($(document).height() > 1000) {
            if($(document).scrollTop() > 100) {
                yesyes();
            } else {
                byebye();
            }
        } else {
            byebye();
        }
    } else {
        byebye();        
    }
});

$(window).bind("scroll",function(e){
    if($(document).width() > 551) {
        if($(document).scrollTop() > 100) {
            byebye();
            yesyes();
        }
    }
});

});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment