Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =========================================
- // = Fixed Header =
- // =========================================
- add_action('wp_enqueue_scripts', 'add_my_code');
- function add_my_code() {
- add_action( 'print_footer_scripts', 'my_footer_script' );
- }
- function my_footer_script() { ?>
- <script type="text/javascript">
- jQuery(function($) {
- var $filter = $('#header');
- var $filterSpacer = $('<div />', {
- "class": "filter-drop-spacer",
- "height": $filter.outerHeight()
- });
- if ($filter.size())
- {
- $(window).scroll(function ()
- {
- if (!$filter.hasClass('fix') && $(window).scrollTop() > $filter.offset().top)
- {
- $filter.before($filterSpacer);
- $filter.addClass("fix");
- }
- else if ($filter.hasClass('fix') && $(window).scrollTop() < $filterSpacer.offset().top)
- {
- $filter.removeClass("fix");
- $filterSpacer.remove();
- }
- });
- }
- });
- </script>
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement