Twenty Thirteen: further performance for functions.js scroll event callback, props obenland. See #23875.
git-svn-id: https://develop.svn.wordpress.org/trunk@24005 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
e6b986ec2b
commit
d0a418557f
@ -223,7 +223,7 @@ function twentythirteen_scripts_styles() {
|
||||
wp_enqueue_script( 'jquery-masonry' );
|
||||
|
||||
// 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.
|
||||
wp_enqueue_style( 'twentythirteen-style', get_stylesheet_uri() );
|
||||
|
@ -5,12 +5,13 @@
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
var html = $( 'html' ),
|
||||
body = $( 'body' ),
|
||||
navbar = $( '#navbar' ),
|
||||
_window = $( window ),
|
||||
navbarOffset = -1,
|
||||
toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
|
||||
var html = $( 'html' ),
|
||||
body = $( 'body' ),
|
||||
navbar = $( '#navbar' ),
|
||||
_window = $( window ),
|
||||
toolbarOffset = body.is( '.admin-bar' ) ? 28 : 0,
|
||||
navbarOffset = navbar.offset().top - toolbarOffset,
|
||||
scrollOffsetMethod = ( typeof window.scrollY === 'undefined' ),
|
||||
adjustFooter,
|
||||
adjustAnchor;
|
||||
|
||||
@ -48,16 +49,16 @@
|
||||
/**
|
||||
* Displays the fixed navbar based on screen position.
|
||||
*/
|
||||
_window.on( 'scroll.twentythirteen', function() {
|
||||
var scrollOffset = ( typeof window.scrollY === 'undefined' ) ? document.documentElement.scrollTop : window.scrollY;
|
||||
if ( navbarOffset < 0 )
|
||||
navbarOffset = navbar.offset().top - toolbarOffset;
|
||||
|
||||
if ( scrollOffset >= navbarOffset && _window.innerWidth() > 644 )
|
||||
html.addClass( 'navbar-fixed' );
|
||||
else
|
||||
html.removeClass( 'navbar-fixed' );
|
||||
} );
|
||||
if ( _window.innerWidth() > 644 ) {
|
||||
_window.on( 'scroll.twentythirteen', function() {
|
||||
var scrollOffset = scrollOffsetMethod ? document.documentElement.scrollTop : window.scrollY;
|
||||
|
||||
if ( scrollOffset > navbarOffset )
|
||||
html.addClass( 'navbar-fixed' );
|
||||
else
|
||||
html.removeClass( 'navbar-fixed' );
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows clicking the navbar to scroll to top.
|
||||
|
Loading…
Reference in New Issue
Block a user