Changeset 49855
- Timestamp:
- 12/21/2020 03:14:15 PM (4 years ago)
- Location:
- branches/5.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.6
-
branches/5.6/src/wp-content/themes/twentytwentyone/assets/js/primary-navigation.js
r49829 r49855 151 151 } ); 152 152 153 /** 154 * Close menu and scroll to anchor when an anchor link is clicked. 155 * Adapted from TwentyTwenty. 156 */ 157 document.addEventListener( 'click', function( event ) { 158 // If target onclick is <a> with # within the href attribute 159 if ( event.target.hash && event.target.hash.includes( '#' ) ) { 160 wrapper.classList.remove( id + '-navigation-open', 'lock-scrolling' ); 161 twentytwentyoneToggleAriaExpanded( mobileButton ); 162 // Wait 550 and scroll to the anchor. 163 setTimeout(function () { 164 var anchor = document.getElementById(event.target.hash.slice(1)); 165 anchor.scrollIntoView(); 166 }, 550); 167 } 168 } ); 169 153 170 document.getElementById( 'site-navigation' ).querySelectorAll( '.menu-wrapper > .menu-item-has-children' ).forEach( function( li ) { 154 171 li.addEventListener( 'mouseenter', function() {
Note: See TracChangeset
for help on using the changeset viewer.