Created
February 17, 2015 07:44
-
-
Save siamkreative/57f53e505b1b6dabf5d6 to your computer and use it in GitHub Desktop.
Update Javascript Variable if WordPress Admin Bar is enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function ($) { | |
// The long version | |
var scrollOffset; | |
if ($('body').hasClass('admin-bar')) { | |
scrollOffset = 64; | |
} else { | |
scrollOffset = 32; | |
} | |
// The slightly shorter version | |
var scrollOffset; | |
if ($('body').hasClass('admin-bar')) | |
scrollOffset = 64; | |
else | |
scrollOffset = 32; | |
// The shorthand | |
var scrollOffset = $('body').hasClass('admin-bar') ? 64 : 32; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment