1/** 2 * Makes the header cart content scrollable if the height of the dropdown exceeds the window height. 3 * Mouseover is used as items can be added to the cart via ajax and we'll need to recheck. 4 */ 5( function () { 6 if ( 7 document.body.classList.contains( 'woocommerce-cart' ) || 8 document.body.classList.contains( 'woocommerce-checkout' ) || 9 window.innerWidth < 768 || 10 ! document.getElementById( 'site-header-cart' ) 11 ) { 12 return; 13 } 14 15 window.addEventListener( 'load', function () { 16 const cart = document.querySelector( '.site-header-cart' ); 17 18 cart.addEventListener( 'mouseover', function () { 19 const windowHeight = window.outerHeight, 20 cartBottomPos = 21 this.querySelector( 22 '.widget_shopping_cart_content' 23 ).getBoundingClientRect().bottom + this.offsetHeight, 24 cartList = this.querySelector( '.cart_list' ); 25 26 if ( cartBottomPos > windowHeight ) { 27 cartList.style.maxHeight = '15em'; 28 cartList.style.overflowY = 'auto'; 29 } 30 } ); 31 } ); 32} )();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.