Skip to content

Instantly share code, notes, and snippets.

@atsea
Created August 12, 2015 12:50
Show Gist options
  • Save atsea/6b606b9cfb4f8cd3dd41 to your computer and use it in GitHub Desktop.
Save atsea/6b606b9cfb4f8cd3dd41 to your computer and use it in GitHub Desktop.
jQuery: animate opacity on slideToggle
/**
* UDBrand header
* http://stackoverflow.com/questions/21918477/jquery-toggle-opacity-on-click-using-css-animation
* http://stackoverflow.com/questions/18995647/jquery-make-global-variable
*/
var current_width;
var pixel_ratio;
var logo_big;
$('#searchdiv').on('click', function(e){
$('.dropDown').slideToggle(300);
if ( current_width < 768) {
logo_big = $('#ud_primary_logo_big');
// logo_big is not visible lets make it visible.
if(logo_big.css('opacity') === '0') {
logo_big.animate({
opacity: '1',
width: '177px'
});
}
else {
logo_big.animate({
opacity: '0',
width: '0'
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment