Tagged: 

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #785213

    Hello
    In this page: https://www.domodeco.fr/carnet-d-adresses I have 15 filter buttons

    The problem is that page on mobile is not user frindly because when you touch on the filter to display the results the user do not see the results, or do not see that something has changed in the page, because the changes are out of the mobile view.

    What JS do I have to add to make like this: if button filter clicked then scroll down to div.grid-sort-container

    And it must works both on desktop and mobile… so I think for destktop it will be something like:

    jQuery('body').on('click', '.inner_sort_button', function() {
    jQuery("html, body").animate({ scrollTop: jQuery('.grid-sort-container').offset().top}, 'slow');

    and for mobile:

    if('ontouchend' in document) {
    jQuery("html, body").animate({ scrollTop: jQuery('.grid-sort-container').offset().top}, 'slow');

    Those code I give are jsut ideas of course….

    Thanks

    #786128

    Hey pako69,

    Thank you for using Enfold.

    Please try this script in the functions.php file:

    function ava_custom_script_fix(){
    ?>
    <script>
    (function($){
    	function e() {
    		$('.sort_by_cat a').on('click', function() {
    			$('html, body').animate({
    				scrollTop: $(".grid-sort-container").offset().top
    			}, 1000);
    		});
    	}
       	
       	e();
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_custom_script_fix');

    Best regards,
    Ismael

    #786195

    Ismael: you rock!
    A big thank :)

    > Sure this is a simple tip that should be somewhere in your FAQs/Tips, don’t you think ?

    #786212

    And If someone is looking for the same thing but with a Masonry elements:
    > Note the ‘- 70’ is specific because I’m using the fixed header

    function ava_custom_script_fix(){
    ?>
    <script>
    (function($){
        function e() {
            $('.av-sort-by-term a').on('click', function() {
                $('html, body').animate({
                    scrollTop: $(".av-masonry-container").offset().top - 70
                }, 1000);
            });
        }
        
        e();
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_custom_script_fix');
    • This reply was modified 7 years, 7 months ago by pako69.
    #786283

    Hi,

    Thanks for sharing, much appreciated. And you’re right, Ismael does rock :-)

    Best regards,
    Rikard

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.