Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1359326

    Hey Kriesi-Team,

    i would like to make the masonry category-filter on my page (see link) to stick under the main menu when scrolling down. As the “all” category has quite some entries, this would help improve user experience.

    Thanks for your help!

    Best regards,
    Mike

    #1359331

    Hey Mike1050,
    Thanks for your question, to make the masonry sort sticky on that page for tablets and above, try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor:

    function sticky_masonry_sort_waypoint() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
      (function($){
      	var width = $(window).width();
        var $stickyTop = $('#top.page-id-102 .av-sort-by-term');
        if (width >= 767) {
        $stickyTop.waypoint(function(direction) {
          if (direction === 'down') {
             $stickyTop.addClass('sticky-top');
          }
          if (direction === 'up') {
             $stickyTop.removeClass('sticky-top');
          }
        }, {
          offset: '118px'
        });
        }
      })(jQuery);
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'sticky_masonry_sort_waypoint');

    and this css in the General Styling ▸ Quick CSS field:

    .sticky-top {
        position:fixed!important;
        top:118px!important;
        z-index:510!important;
        background-color: #fff;
    }

    After applying the css, please clear your browser cache and check.

    Best regards,
    Mike

    #1362172

    Hey Mike,

    thanks for your solution – it works!

    2 more questions please:

    – Do you think its possible to add the following functionality: When selecting a category in the filter after scrolling down, the disply sometimes doesn’t show the products, depending on how long the selected category is. So if users don’t intuitively scroll up, they may may be wondering where the products are. Is it possible to ad a kind of “jump to the start of the selection”?

    – To improve user experience on mobile: Is it possible to ad a “beginning of page” icon, which displays after scrolling down on mobile (and eventually on desktop as well)?

    Thank you for your help!

    Best regards
    Mike

    #1362294

    Hi,
    Thanks for your patience, to show the scroll-up button for mobile please try adding the css to your Quick CSS:

    @media only screen and (max-width: 767px) {
    .responsive #top #scroll-top-link {
        display: block;
    }
    }

    For the /backhandwerk/ page, your question was scrolling to the top after clicking a category, but when I check you need to be at the top to click on a category.
    So I’m not seeing where there a need here.
    Please try explaining further, perhaps a screenshot would help.

    Best regards,
    Mike

    #1363208

    Hi Mike,

    thanks for your Input!

    – the scroll-up button is great. Can it just be on the /backhandwerk/ page? As this is the only “scroll-heavy” page. Is it possible to define a color for the square-form of the scroll-up button?

    – as you recommended on july 24th, i added the CSS to make the category filter sticky (you need to be logged out or in private window to make the sticky filter work). So now it stays with the content. When users are scrolling down (and the filter sticks) and than choosing a category (with fewer products) it seems that there are no products shown, although there are – This is especially when scrolling down in the “All” category, which is where most users start to scroll i guess. The reason is, that the page stays down and. Thats why the auto-scroll-up-funtionality after selecting a category would be so helpful. I tried to explain this with some screenshots. Please also consider the file names. Hope this clarifies the issue.

    Thanks for you help!

    Best regards,
    Mike

    #1363755

    Hi,
    Thank you for your patience, to only have the scroll-up button for mobile on the /backhandwerk/ page, please change above the css to this:

    @media only screen and (max-width: 767px) {
    .responsive #top.page-id-102  #scroll-top-link {
        display: block;
    }
    }

    To add a “scroll to the top” function when the masonry sort option is clicked for the /backhandwerk/ page only, try adding this code to the end of your functions.php file in Appearance ▸ Editor:

    function custom_masonry_sort_scroll_to_top_script() { ?>
      <script>
    window.addEventListener('DOMContentLoaded', function() {
      (function($){
    $("#top.page-id-102 a.avia_show_sort").click(function(e) {
    	setTimeout(function(){
      $("html, body").animate({ scrollTop: 0 }, "slow");
      return false;
    	},1500);
    	e.preventDefault();
    });
    })(jQuery);
    });
    </script>
      <?php
    }
    add_action('wp_footer', 'custom_masonry_sort_scroll_to_top_script');

    Please note that in the script I had to add a setTimeout of 1500ms (1.5 seconds) to allow the images to show before scrolling to the top so to not conflict with the masonry display animation.
    You can try adjusting higher or lower if you wish, but this may be an over all limitation because of how the masonry javascript works.
    In my tests the setTimeout of 1500ms works well if the user scrolls down a bit before clicking a sort link, please give this a try.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Masonry categories as sticky menü’ is closed to new replies.