Make WordPress Core

Changeset 39183


Ignore:
Timestamp:
11/09/2016 04:12:35 PM (9 years ago)
Author:
karmatosed
Message:

Twenty Seventeen: Fixes focused controls hidden by top menu.

When a page is scrolled, the top nav menu became fixed. This resolves that.

Props afercia, Fencer04, davidakennedy
Fixes #38476

Location:
trunk/src/wp-content/themes/twentyseventeen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyseventeen/assets/js/global.js

    r39081 r39183  
    2828
    2929    /**
     30     * Ensure the sticky navigation doesn't cover current focused links
     31     */
     32    $( '#content a, #colophon a' ).focus( function() {
     33        if ( $navigation.hasClass( 'site-navigation-fixed' ) ) {
     34            var windowScrollTop = $( window ).scrollTop(),
     35                fixedNavHeight = $navigation.height(),
     36                itemScrollTop = $( this ).offset().top,
     37                offsetDiff = itemScrollTop - windowScrollTop;
     38
     39            // Account for Admin bar.
     40            if ( $( '#wpadminbar' ).length ) {
     41                offsetDiff -= $( '#wpadminbar' ).height();
     42            }
     43
     44            if ( offsetDiff < fixedNavHeight ) {
     45                $( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 600);
     46            };
     47        }
     48    } );
     49
     50    /**
    3051     * Sets properties of navigation
    3152     */
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r39073 r39183  
    380380    wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '1.0', true );
    381381
     382    wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.2', true );
     383
    382384    wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
    383385
    384386    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
    385387        wp_enqueue_script( 'comment-reply' );
    386     }
    387 
    388     // Scroll effects (only loaded on front page).
    389     if ( is_front_page() ) {
    390         wp_enqueue_script( 'jquery-scrollto', get_template_directory_uri() . '/assets/js/jquery.scrollTo.js', array( 'jquery' ), '2.1.2', true );
    391388    }
    392389}
Note: See TracChangeset for help on using the changeset viewer.