• Resolved chenisra

    (@chenisra)


    Hey,
    I want the user to not be able to scroll the page while the fly cart is open.
    It is possible?

    The overlay does not prevent scrolling the page.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Henry N

    (@henrynguyen259)

    Try this:

    <script type="text/javascript">    
            (function($) { 
                $(document).ready(function(event) { 
                    $(document.body).on('woofc_hide_cart', function(){
                        $(this).css('overflow-y', 'auto');
                    });
                    $(document.body).on('woofc_show_cart', function(){
                        $(this).css('overflow-y', 'hidden');
                    });
                });
            })(jQuery);
        </script>
    Thread Starter chenisra

    (@chenisra)

    thanks,
    it’s work

    Work like a charm, thank man!

    Update! The code not work on mobile or pc if user resize the screen.

    Try this!

    
    <script type="text/javascript">
    /* stop body from scrolling while openning flycart */
    	(function($) { 
    		$(document).ready(function(event) {
    			const body = document.querySelector("body");
    			$(document.body).on('woofc_hide_cart', function(){
    				if (body.classList.contains("woofc-show")) {
    				// Disable scroll
    				body.style.overflow = "hidden";
    				} else {
    				// Enable scroll
    				body.style.overflow = "auto";
    				}
                    	});
    			$(document.body).on('woofc_show_cart', function(){
                   		    	if (body.classList.contains("woofc-show")) {
    				// Disable scroll
    				body.style.overflow = "hidden";
    				} else {
    				// Enable scroll
    				body.style.overflow = "auto";
    				}
                  	 	 });
               	 }); 
            })(jQuery);
    </script>			
    
    • This reply was modified 2 years, 6 months ago by thangbom9o.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘stop scroll optin when fly cart open’ is closed to new replies.