Make WordPress Core

Changeset 30838 for trunk


Ignore:
Timestamp:
12/12/2014 11:58:06 PM (12 years ago)
Author:
lancewillett
Message:

Twenty Fifteen: update scroll functionality to make sure child menu items are always reachable.

Props iamtakashi, fixes #30674.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentyfifteen/functions.php

    r30832 r30838  
    227227        }
    228228
    229         wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20141010', true );
     229        wp_enqueue_script( 'twentyfifteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20141212', true );
    230230        wp_localize_script( 'twentyfifteen-script', 'screenReaderText', array(
    231231                'expand'   => '<span class="screen-reader-text">' . esc_html__( 'expand child menu', 'twentyfifteen' ) . '</span>',
  • trunk/src/wp-content/themes/twentyfifteen/js/functions.js

    r30808 r30838  
    6767                var windowPos = $window.scrollTop();
    6868
    69                 if ( 955 <= windowWidth && sidebarHeight + adminbarOffset < bodyHeight ) {
    70                         if ( sidebarHeight + adminbarOffset > windowHeight ) {
    71                                 if ( windowPos > lastWindowPos ) {
    72                                         if ( top ) {
    73                                                 top = false;
    74                                                 topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
    75                                                 $sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
    76                                         } else if ( ! bottom && windowPos + windowHeight > sidebarHeight + $sidebar.offset().top ) {
    77                                                 bottom = true;
    78                                                 $sidebar.attr( 'style', 'position: fixed;bottom: 0;' );
    79                                         }
    80                                 } else if ( windowPos < lastWindowPos ) {
    81                                         if ( bottom ) {
    82                                                 bottom = false;
    83                                                 topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
    84                                                 $sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
    85                                         } else if ( ! top && windowPos + adminbarOffset < $sidebar.offset().top ) {
    86                                                 top = true;
    87                                                 $sidebar.attr( 'style', 'position: fixed;' );
    88                                         }
    89                                 } else {
    90                                         top = bottom = false;
     69                if ( 955 > windowWidth ) {
     70                        return;
     71                }
     72
     73                if ( sidebarHeight + adminbarOffset > windowHeight ) {
     74                        if ( windowPos > lastWindowPos ) {
     75                                if ( top ) {
     76                                        top = false;
    9177                                        topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
    9278                                        $sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
     79                                } else if ( ! bottom && windowPos + windowHeight > sidebarHeight + $sidebar.offset().top && sidebarHeight + adminbarOffset < bodyHeight ) {
     80                                        bottom = true;
     81                                        $sidebar.attr( 'style', 'position: fixed; bottom: 0;' );
    9382                                }
    94                         } else if ( ! top ) {
    95                                 top = true;
    96                                 $sidebar.attr( 'style', 'position: fixed;' );
     83                        } else if ( windowPos < lastWindowPos ) {
     84                                if ( bottom ) {
     85                                        bottom = false;
     86                                        topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
     87                                        $sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
     88                                } else if ( ! top && windowPos + adminbarOffset < $sidebar.offset().top ) {
     89                                        top = true;
     90                                        $sidebar.attr( 'style', 'position: fixed;' );
     91                                }
     92                        } else {
     93                                top = bottom = false;
     94                                topOffset = ( $sidebar.offset().top > 0 ) ? $sidebar.offset().top - adminbarOffset : 0;
     95                                $sidebar.attr( 'style', 'top: ' + topOffset + 'px;' );
    9796                        }
     97                } else if ( ! top ) {
     98                        top = true;
     99                        $sidebar.attr( 'style', 'position: fixed;' );
    98100                }
    99101
Note: See TracChangeset for help on using the changeset viewer.