What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: How to make page scroll to top when selecting and unselecting the filter .

Solved

How to make page scroll to top when selecting and unselecting the filter .

Not applicable

Hello there , 

 

Is there any way to make it appear to look like the site or page to scroll completely to the top when selecting or unselecting any filter from the filter options. 

 

 

 

 

Thank You !!!

Accepted Solution (1)

theycallmemakka
Shopify Partner
1744 424 443

This is an accepted solution.

Hi @Anonymous ,

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<script>
function scrollToTop() {
  window.scrollTo({
    top: 0,
    behavior: 'smooth'
  });
}
document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('change', function(event) {
        var target = event.target;

        if (target.matches('.facet-checkbox input')) {
            setTimeout(function() {
                scrollToTop();
            }, 600);
        }
    });
});
</script>

If you require further help to optimize your store, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Makka

 

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

View solution in original post

Replies 6 (6)

Dan-From-Ryviu
Shopify Partner
10264 2039 2110

Hi @Anonymous 

You can try to use this code in your theme.liquid file before </body> tag in Online store > Themes > Edit code 

 

<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script>
 $(document).ready(function(){
   $(".facets__item .facet-checkbox").click(function() {
    $(".collection-grid-section").animate({ scrollTop: 0 }, "slow"); 
   });
});
</script>

 

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

Not applicable

Hi ,

 

It is not working .

Dan-From-Ryviu
Shopify Partner
10264 2039 2110

Please try to update code like this and check again 

<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
<script>
 jQuery(document).ready(function($){
   $(".facets__item .facet-checkbox").click(function() {
    $(".collection-grid-section").animate({ scrollTop: 0 }, "slow"); 
   });
});
</script>

- Helpful? Like and Accept solution! Or Support me: Buy Coffees
- Reton: Loyalty & Rewards - Earn points through tasks, redeem for discounts, and enjoy exclusive VIP rewards!
- Ryviu - Reviews & QA app: Collect product reviews, import reviews from AliExpress, Amazon, Etsy, Walmart, Shopee, Dhgate and CSV.
- Lookfy Gallery: Lookbook Image: Easy and fast to create Photo Gallery, Lookbook, Shop The Look.
- Reelfy‑Shoppable Videos+Reels: Create shoppable videos to engage customers and drive more sales.
- Enjoy 1 month of Shopify for $1. Sign up now.

theycallmemakka
Shopify Partner
1744 424 443

This is an accepted solution.

Hi @Anonymous ,

 

Follow these Steps:

1) Go to Online Store
2) Edit Code
3) Find theme.liquid file

4) Add the following code in the bottom of the file above </body> tag

<script>
function scrollToTop() {
  window.scrollTo({
    top: 0,
    behavior: 'smooth'
  });
}
document.addEventListener('DOMContentLoaded', function() {
    document.addEventListener('change', function(event) {
        var target = event.target;

        if (target.matches('.facet-checkbox input')) {
            setTimeout(function() {
                scrollToTop();
            }, 600);
        }
    });
});
</script>

If you require further help to optimize your store, please don't hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
Makka

 

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com

Not applicable

Great , it is working .

 

Thank You !!!!

theycallmemakka
Shopify Partner
1744 424 443

Happy to hear that work. If you require any other help, feel free to reach me out.

 

 

Support Me: Buy me a Coffee


For quick response - Message Me


Ping me at: theycallmemakka@gmail.com