HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/shootinschool/wp-content/themes/storefront/assets/js/woocommerce/header-cart.js
/**
 * Makes the header cart content scrollable if the height of the dropdown exceeds the window height.
 * Mouseover is used as items can be added to the cart via ajax and we'll need to recheck.
 */
( function () {
	if (
		document.body.classList.contains( 'woocommerce-cart' ) ||
		document.body.classList.contains( 'woocommerce-checkout' ) ||
		window.innerWidth < 768 ||
		! document.getElementById( 'site-header-cart' )
	) {
		return;
	}

	window.addEventListener( 'load', function () {
		const cart = document.querySelector( '.site-header-cart' );

		cart.addEventListener( 'mouseover', function () {
			const windowHeight = window.outerHeight,
				cartBottomPos =
					this.querySelector(
						'.widget_shopping_cart_content'
					).getBoundingClientRect().bottom + this.offsetHeight,
				cartList = this.querySelector( '.cart_list' );

			if ( cartBottomPos > windowHeight ) {
				cartList.style.maxHeight = '15em';
				cartList.style.overflowY = 'auto';
			}
		} );
	} );
} )();