WordPress.org

Make WordPress Core

Ticket #42598: 42598.2.diff

File 42598.2.diff, 895 bytes (added by jasonlcrane, 3 years ago)

Update to conform to WordPress' JavaScript Coding Standards, JSHint checks passed

  • src/wp-content/themes/twentyseventeen/assets/js/global.js

    diff --git a/src/wp-content/themes/twentyseventeen/assets/js/global.js b/src/wp-content/themes/twentyseventeen/assets/js/global.js
    index 6e2f42902e..8890665626 100644
    a b  
    182182                if ( $navigation.length ) {
    183183                        setNavProps();
    184184                        adjustScrollClass();
     185
     186                        // Scroll if something is in the URL hash and an element matching the hash is present on the page.
     187                        if ( window.location.hash && $( window.location.hash ).length ) {
     188                                // Set scrollTop in a timeout so position is set correctly.
     189                                setTimeout( function() {
     190                                        $( window ).scrollTop( $( window ).scrollTop() - navigationOuterHeight - 10 );
     191                                }, 100 );
     192
     193                        }
    185194                }
    186195
    187196                // If 'Scroll Down' arrow in present on page, calculate scroll offset and bind an event handler to the click event.