Viewing 19 posts - 1 through 19 (of 19 total)
  • Author
    Posts
  • #1228729

    Hi,
    I added Unstick topbar option in Enfold theme options > Header > Header Behaviour and it works great on desktop.
    But it doesn’t work on mobile and my full width slider is now hidden :-(
    Could you please help me with this?
    If needed, you can find a link and credentials to my website in private content.
    Thanks a lot!

    #1228736

    Hey fcp,

    Add this to quick css:

    @media only screen and (max-width: 769px) {
    .html_header_sticky.html_header_transparency #top #wrap_all #header, .html_header_sticky #top #wrap_all #header {
        position: relative;
    }}

    Best regards,
    Jordan Shannon

    #1228863

    Hi Jordan,
    Thanks for your reply.
    Unfortunately, this code doesn’t change anything.

    #1228917

    Hi,

    Did you add the code to the very top of quick css so it runs first? Also, clear the cache a few times over.

    Best regards,
    Jordan Shannon

    #1229003

    Hi Jordan,
    I tried many things:
    – add the code to the very top of my Quick CSS
    – add !important to the code
    – clear browser cache and Autoptimize cache many times
    – add the code to the very top of my style.css file
    …but it doesn’t work.

    #1229505

    For information, my slider on mobiles and part of my slider on tablets are hidden because of this code I added to make header sticky on mobiles and tablets:

    @media only screen and (max-width: 989px) {
    .responsive #top #wrap_all #header {
    position: fixed!important;}
    }

    How could I solve this issue?
    Thanks!

    #1229947

    Hi,
    Sorry for the late reply, since the header is sticky for mobile we will need to add padding to the top of the page to show the slider.
    Please try this code in the General Styling > Quick CSS field or in the WordPress > Customize > Additional CSS field:

    @media only screen and (max-width: 374px){
    .responsive #top #main {
        padding-top: 45% !important;
    }
    }
    @media only screen and (max-width: 430px) and (min-width: 375px){
    .responsive #top #main {
        padding-top: 34% !important;
    }
    }
    @media only screen and (max-width: 767px) and (min-width: 431px){
    .responsive #top #main {
        padding-top: 22% !important;
    }
    }
    @media only screen and (max-width: 989px) and (min-width: 768px) {
    .responsive.html_mobile_menu_tablet.html_header_top #top #main {
        padding-top: 16% !important;
    }
    }

    Please note that there is not one percentage we can use to make a fluid transition across all possible screen sizes, such as if you test by resizing your browser window, but if you test actual device sizes such as 320px, 425px & 768px with the developer tools you should find that this works well.

    Best regards,
    Mike

    #1229959

    Hi Mike,
    Thanks for your reply!
    Header height seems to be always the same on mobiles (142px) and tablets (122px).
    So I modified your code to this one and it seems to work well on all screen sizes:

    @media only screen and (max-width: 767px) {
    .responsive #top #main {
        padding-top: 142px!important;
    }
    }
    @media only screen and (min-width: 768px) and (max-width: 989px) {
    .responsive #top #main {
        padding-top: 122px!important;
    }
    }

    Do you see any restriction to this code? Could it be ok?

    #1230267

    Hi,
    Thanks for the feedback, and good catch, this looks fine. Unless there is anything else we can assist with on this issue, shall we close this then?

    Best regards,
    Mike

    #1230279

    Hi Mike,
    Thanks for your reply.
    Maybe you could help me with something else:
    I enabled the third option in Enfold theme options > Header > Header Behaviour to make secondary menu disappear when scrolling down.
    It works on desktop, but not on tablet and mobile.
    What do I need to do to achieve this?
    Thanks a lot!

    #1230896

    Hi,
    Sorry for the late reply, this script & css will hide the top bar on scroll down and show on scroll up for mobile.
    Try adding this code to the end of your functions.php file in Appearance > Editor:

    function custom_hide_top_script(){
      ?>
      <script>
    ( function( $ ) {
    
      'use strict';
    
      var $window       = $( window );
      var lastScrollTop = 0;
      var $header       = $( '#header_meta' );
      var headerBottom  = $header.position().top + $header.outerHeight( true );
    
      $window.scroll( function() {
              var windowTop  = $window.scrollTop();
    
              // Add custom sticky class 
              if ( windowTop >= headerBottom ) {
                  $header.addClass( 'top-sticky' );
              } else {
                  $header.removeClass( 'top-sticky' );
                  $header.removeClass( 'top-show' );
              }
    
              // Show/hide
              if ( $header.hasClass( 'top-sticky' ) ) {
                  if ( windowTop <= headerBottom || windowTop < lastScrollTop ) {
                      $header.addClass( 'top-show' );
                  } else {
                      $header.removeClass( 'top-show' );
                  }
              }
              lastScrollTop = windowTop;
      } );
    } ( jQuery ) );
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_hide_top_script');

    Then add this code in the General Styling > Quick CSS field or in the WordPress > Customize > Additional CSS field:

    @media only screen and (max-width: 1023px){
    .top-sticky {
    	display: none;
    }
    .top-sticky.top-show {
    	display: block;
    }
    .responsive #top #wrap_all #header + #header_meta.top-sticky {
        top: 0 !important;
    }
    }

    Then clear your browser cache and check.
    **Please note that if testing on a desktop with a mobile sized window you may need to reload the page for the window size to be recognized. This doesn’t affect actual mobile devices just resized desktop browsers.

    Best regards,
    Mike

    #1230912

    Hi Mike,
    Thanks for your reply and your work.
    It seems to work, but the secondary menu behavior is not exactly the same on mobile and tablet than on desktop.
    On desktop, the secondary menu is scrolled up (it slides to the top) and then disappears.
    But on mobile and tablet, it only disappear.
    I’m not sure to be clear at all :-D
    So I made a short video in private content to explain.
    How could I fix this?
    Thanks a lot!

    #1231488

    Hi,
    Sorry for the late reply, I have adjusted the script to :

    function custom_hide_top_script(){
      ?>
      <script>
    ( function( $ ) {
    
      'use strict';
    
      var $window       = $( window );
      var $header       = $( '#header_meta' );
      $window.scroll( function() {
              var windowTop  = ($(window).scrollTop() <= 0);
              if ( windowTop ) {
                  $header.addClass( 'top-show' );
                  $header.removeClass( 'top-hide' );
              } else {
                  $header.removeClass( 'top-show' );
                  $header.addClass( 'top-hide' );
              }
      } );
    } ( jQuery ) );
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_hide_top_script');

    and the css to:

    @media only screen and (max-width: 1023px){
    #header_meta.top-hide {
    	min-height: 0;
    	height: 0;
    	visibility:hidden;
        opacity:0;
        transition:min-height 1s linear;
    }
    #header_meta.top-show {
    	min-height: 61px;
        visibility:visible;
        opacity:1;
        transition:min-height 1s linear;
    }
    }

    Please clear your browser cache and check.

    Best regards,
    Mike

    #1231495

    Hi Mike,
    Thanks for your reply.
    I checked my browser and the result is not exactly what I wanted :-(
    The behavior is very strange on tablets. My main menu goes down or moves alone…
    On mobiles, this is not very beautiful. When scrolling a few pixels down only, menu goes up, so there is white space between my main menu and my slider.
    I added a video in private content.
    In fact when I opened this thread, I thought there would be an easy way to do this. Indeed, this behavior is included in your theme and works perfectly on desktop. Isn’t there an easy way to apply the same code and get EXACTLY the same result and behavior on tablets and mobiles, using your theme content?

    #1231507

    Hi,
    The “Sticky Header”, “Shrinking Header” & “Unstick topbar” theme options are not designed to work on mobile devices, so while we are attempting to duplicate this, it is not EXACTLY the same.
    I believe we can get close, but I can’t say that this customization will be EXACTLY the same.

    Best regards,
    Mike

    #1231552

    Hi Mike,
    I understand.
    So if you have any idea to fix those strange behaviors, it would be great! ;-)

    #1231706

    Hi,
    Sorry for the late reply and thanks for your patience. So I re-wrote the script and disabled your css for the fixed mobile header and I found that the header and topbar were scrolling smoothly but the slider was not, so once I adjusted for that it looks smooth.
    Please clear your browser cache and check.

    This is the new script:

    function custom_hide_top_script(){
      ?>
      <script>
    (function($){
      $(window).scroll(function(){
      	var width = $(window).width();
      	var scrolled = $(window).scrollTop();
     if ( scrolled >= 60 && width <= 767) { 	
      $( '#header' ).each(function() {
      $(this).css({'background-color':'#ffffff','position':'fixed','top':'-60px'});
      $('#full_slider_1').css({'padding-top':'130px'});
      });
     }
     else if ( scrolled <= 60 && width <= 767){
     	$( '#header' ).each(function() {
     	$(this).css({'background-color':'#ffffff','position':'relative','top':'0'});
     	$('#full_slider_1').css({'padding-top':'0px'});
     });
      } else {}
      });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_hide_top_script');

    Best regards,
    Mike

    #1231791

    Hi Mike,

    Thank you so much for your work!
    I don’t understand what you mean when you say “your child theme stylesheet needs to include the top header of the file”? :-S

    I made a new video of the menu behavior in private content.
    1) So on desktop nothing changed.

    2) Then on mobile, it seems to be ok. There is only a little jump of the header when it begins to disappear…
    But I have a problem on mobiles, because I’m waiting an answer on another thread which will change the menu appearance: https://kriesi.at/support/topic/add-icon-next-to-shopping-cart-icon/.
    Indeed, I want to hide my secondary menu on mobiles (but keep the phone number area) and add a “My account” icon just next to my shopping cart. So I will have to adjust your function after that, but maybe I could do it by myself…

    3) As you can see, it doesn’t work well on tablets. It cuts my menu in the middle and also makes a jump.

    4) And when I come back to the desktop, it doesn’t work anymore. My main menu is not even sticky anymore…

    #1232247

    Hi,
    Thank for the feedback, glad to hear it’s working for mobile, I had not looked at the tablet view yet, to expand this script for tablet I adjusted to this:

    function custom_hide_top_script(){
      ?>
      <script>
    (function($){
      $(window).scroll(function(){
      	var width = $(window).width();
      	var scrolled = $(window).scrollTop();
     if ( scrolled >= 60 && width <= 480) { 	
      $( '#header' ).each(function() {
      $(this).css({'background-color':'#ffffff','position':'fixed','top':'-60px'});
      $('.responsive #top #wrap_all #main').css({'padding-top':'113px'});
      });
     }
    else if ( scrolled <= 60 && width <= 480){
     	$( '#header' ).each(function() {
     	$(this).css({'background-color':'#ffffff','position':'relative','top':'0'});
     	$('.responsive #top #wrap_all #main').css({'padding-top':'0px'});
     });
      }
    else if ( scrolled >= 30 && width >= 480) { 	
      $( '#header' ).each(function() {
      $(this).css({'background-color':'#ffffff','position':'fixed','top':'-30px'});
      $('.responsive #top #wrap_all #main').css({'padding-top':'113px'});
      });
     }
    else if ( scrolled <= 30 && width >= 480){
     	$( '#header' ).each(function() {
     	$(this).css({'background-color':'#ffffff','position':'relative','top':'0'});
     	$('.responsive #top #wrap_all #main').css({'padding-top':'0px'});
     });
      } else {}
      });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_hide_top_script');

    This is because before 480px your topbar is 60px high & after 480px your topbar is 30px.
    There is still a slight jump on scroll down, this is because the #main container is given zero padding, but we want it to have a 113px offset (padding-top), so on scroll when the top padding is removed from the #main it looks like it is jumping.
    I’m not sure we are going to be able to overcome this.

    Best regards,
    Mike

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