Make WordPress Core

Ticket #23875: 23875.3.diff

File 23875.3.diff, 2.7 KB (added by lancewillett, 11 years ago)
  • wp-content/themes/twentythirteen/js/functions.js

     
    55 */
    66
    77( function( $ ) {
    8         var html          = $( 'html' ),
    9             body          = $( 'body' ),
    10             navbar        = $( '#navbar' ),
    11             _window       = $( window ),
    12             navbarOffset  = -1,
    13             toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
     8        var html               = $( 'html' ),
     9            body               = $( 'body' ),
     10            navbar             = $( '#navbar' ),
     11            _window            = $( window ),
     12            toolbarOffset      = body.is( '.admin-bar' ) ? 28 : 0,
     13            navbarOffset       = navbar.offset().top - toolbarOffset,
     14            scrollOffsetMethod = ( typeof window.scrollY === 'undefined' ),
     15            timer              = 0,
    1416            adjustFooter,
    1517            adjustAnchor;
    1618
     
    4850        /**
    4951         * Displays the fixed navbar based on screen position.
    5052         */
    51         _window.on( 'scroll.twentythirteen', function() {
    52                 var scrollOffset = ( typeof window.scrollY === 'undefined' ) ? document.documentElement.scrollTop : window.scrollY;
    53                 if ( navbarOffset < 0 )
    54                         navbarOffset = navbar.offset().top - toolbarOffset;
     53        if ( _window.innerWidth() > 644 ) {
     54                _window.on( 'scroll.twentythirteen', function() {
     55                        if ( timer )
     56                                clearTimeout( timer );
    5557
    56                 if ( scrollOffset >= navbarOffset && _window.innerWidth() > 644 )
    57                         html.addClass( 'navbar-fixed' );
    58                 else
    59                         html.removeClass( 'navbar-fixed' );
    60         } );
     58                        timer = setTimeout( function() {
     59                                var scrollOffset = scrollOffsetMethod ? document.documentElement.scrollTop : window.scrollY;
    6160
     61                                if ( scrollOffset > navbarOffset )
     62                                        html.addClass( 'navbar-fixed' );
     63                                else
     64                                        html.removeClass( 'navbar-fixed' );
     65                        }, 50 );
     66                } );
     67        }
     68
    6269        /**
    6370         * Allows clicking the navbar to scroll to top.
    6471         */
  • wp-content/themes/twentythirteen/functions.php

     
    223223                wp_enqueue_script( 'jquery-masonry' );
    224224
    225225        // Loads JavaScript file with functionality specific to Twenty Thirteen.
    226         wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20130211', true );
     226        wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20130416', true );
    227227
    228228        // Loads our main stylesheet.
    229229        wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() );