Twenty Thirteen: further performance for functions.js scroll event callback, props obenland. See #23875.
git-svn-id: http://core.svn.wordpress.org/trunk@24005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e4248830a8
commit
7ed04565bb
|
@ -223,7 +223,7 @@ function twentythirteen_scripts_styles() {
|
||||||
wp_enqueue_script( 'jquery-masonry' );
|
wp_enqueue_script( 'jquery-masonry' );
|
||||||
|
|
||||||
// Loads JavaScript file with functionality specific to Twenty Thirteen.
|
// Loads JavaScript file with functionality specific to Twenty Thirteen.
|
||||||
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20130211', true );
|
wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20130416', true );
|
||||||
|
|
||||||
// Loads our main stylesheet.
|
// Loads our main stylesheet.
|
||||||
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() );
|
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() );
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
body = $( 'body' ),
|
body = $( 'body' ),
|
||||||
navbar = $( '#navbar' ),
|
navbar = $( '#navbar' ),
|
||||||
_window = $( window ),
|
_window = $( window ),
|
||||||
navbarOffset = -1,
|
|
||||||
toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
|
toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
|
||||||
|
navbarOffset = navbar.offset().top - toolbarOffset,
|
||||||
|
scrollOffsetMethod = ( typeof window.scrollY === 'undefined' ),
|
||||||
adjustFooter,
|
adjustFooter,
|
||||||
adjustAnchor;
|
adjustAnchor;
|
||||||
|
|
||||||
|
@ -48,16 +49,16 @@
|
||||||
/**
|
/**
|
||||||
* Displays the fixed navbar based on screen position.
|
* Displays the fixed navbar based on screen position.
|
||||||
*/
|
*/
|
||||||
|
if ( _window.innerWidth() > 644 ) {
|
||||||
_window.on( 'scroll.twentythirteen', function() {
|
_window.on( 'scroll.twentythirteen', function() {
|
||||||
var scrollOffset = ( typeof window.scrollY === 'undefined' ) ? document.documentElement.scrollTop : window.scrollY;
|
var scrollOffset = scrollOffsetMethod ? document.documentElement.scrollTop : window.scrollY;
|
||||||
if ( navbarOffset < 0 )
|
|
||||||
navbarOffset = navbar.offset().top - toolbarOffset;
|
|
||||||
|
|
||||||
if ( scrollOffset >= navbarOffset && _window.innerWidth() > 644 )
|
if ( scrollOffset > navbarOffset )
|
||||||
html.addClass( 'navbar-fixed' );
|
html.addClass( 'navbar-fixed' );
|
||||||
else
|
else
|
||||||
html.removeClass( 'navbar-fixed' );
|
html.removeClass( 'navbar-fixed' );
|
||||||
} );
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows clicking the navbar to scroll to top.
|
* Allows clicking the navbar to scroll to top.
|
||||||
|
|
Loading…
Reference in New Issue