Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1262555

    Hi,

    I created anchors using IDs on one of my pages. Everything works great, but on some screen sizes, those anchors don’t aim the exact part of the page. The reason is because I’m not always using the same way to display my menu (sticky, not sticky, and so on…) and it depends on screen size.
    I made a video in private content to better explain myself.

    So what I would need is adding an offset to those anchors depending on screen size.
    I found the offset-anchor property and tried to use it, but obviously I didn’t do it well :-(
    Could you please help me to achieve this?

    If needed, you can find a link and credentials to my website in private content.
    Thanks a lot!

    #1263434

    Hey fcp,

    Thank you for the inquiry.

    The reason is because I’m not always using the same way to display my menu (sticky, not sticky, and so on…) and it depends on screen size.

    It would be beneficial to the site and for the users if the design and layout of the pages are consistent, and if the location and behavior of the menu or navigation is the same. It gives familiarity and allow users to easily navigate the site without unnecessary strain and confusion.

    If you want to adjust the main container’s offset value, you have to use the avf_header_setting_filter and adjust the value of header_scroll_offset parameter.

    Example:

    
    function avf_header_setting_filter_mod($header) {
    	$header['header_scroll_offset'] = $header['header_scroll_offset'] + 48;
    	return $header;
    }
    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);
    

    You could also insert additional conditional function (e.g is_page, is_archive, is_single) if you want to only apply the changes on certain pages or posts.

    Best regards,
    Ismael

    #1263543

    Hi Ismael,
    Thanks for your reply.

    I completely agree with you and I would love to use the same layout on all devices! And It would be beneficial to the theme if the design and layout of the pages are consistent ;-)
    Indeed, I enabled “Sticky header” and “Unstick topbar” options on desktop because this is the behavior I needed, but this behavior is not available on smaller devices and I needed to add some code to get Sticky header only on them…
    I also asked in this thread: https://kriesi.at/support/topic/unstick-topbar-on-mobile/ and Mike already spent a lot of time trying to make it work, but results were not exactly the same as on desktop.
    So if you have any idea to achieve this or if the next theme update could do it, it would be wonderful! ;-)

    For the moment, I will need to use offset solution and I thank you for this function.
    I need to use it on page-id-921 and page-id-923 only and on mobile and tablet only (maybe I will need to attribute an offset value for mobile and another one for tablet).
    First, I tried to insert additional conditional function for pages like this:

    function avf_header_setting_filter_mod($header) {
    		if ($("#top.page-id-921" || "#top.page-id-923")){
    	$header['header_scroll_offset'] = $header['header_scroll_offset'] + 48;
    	return $header;}
    }
    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);

    or

    function avf_header_setting_filter_mod($header) {
    		if(is_page(array( 921, 923))) {
    	$header['header_scroll_offset'] = $header['header_scroll_offset'] + 48;
    	return $header;}
    }
    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);

    …but it doesn’t work.

    Could you please tell me what I’m doing wrong and what is the good way to insert this and the device size conditions?

    Thanks a lot, Ismael!
    Best regards

    #1263856

    Hi,

    I completely agree with you and I would love to use the same layout on all devices! And It would be beneficial to the theme if the design and layout of the pages are consistent ;-)

    I thought that you are intentionally changing the layout of the navigation on different pages. As you may already know, the layout of the page or the position and behavior of the navigation has to be adjusted a bit on mobile devices because of the screen size, and the layout has to respond to the available space. But you have the option to disable the responsiveness of the site in the Enfold > General Layout > Dimensions > Responsive Site option and maintain the desktop layout on mobile view, but having a non-responsive site is not common nowadays.

    The second snippet above with the is_page function should work, but you have to move the closing curly brace above the return statement.

    function avf_header_setting_filter_mod($header) {
    	if(is_page(array( 921, 923))) {
    	    $header['header_scroll_offset'] = $header['header_scroll_offset'] + 48;
            }
    	return $header;
    }
    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);
    

    Best regards,
    Ismael

    #1265024

    Hi Ismael,
    Thanks for your reply!

    I agree with you about what is really necessary to be adjusted, like classic menu converted in burger menu, etc… But it absolutely doesn’t explain why “Unstick topbar” option does not work on mobile for example, while this option is more necessary on mobile than on desktop, because there is less screen space on mobile.

    I tried your corrected function and it seems to work on screens from 768px, but it doesn’t work on smaller screens and I need it on smaller screens only.
    Could you please tell me what’s wrong?

    Furthermore, I noticed one more thing that works on desktop and not on smaller screens: the “go back to top of page” button (https://imgur.com/Zje0n6O) is displayed on desktop but not on tablet and mobile.
    Could you please tell me how to fix this?

    Thanks a lot for your help!

    #1265506

    Hi,

    It is quite common to disable fixed elements on mobile devices because of the screen limitation, and sticky elements tend to be more of a distraction than help on mobile devices. Scrolling is also much easier on mobile devices compare to desktop because all you need to do is swipe, so menu or navigation support are not really necessary.

    The go back to top button, which is a fixed element, is also disabled because mobile users can tap the top edge of the mobile screen twice to go back to the top of the page. If you would like to bring the button back on mobile view, please use this css code.

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

    Best regards,
    Ismael

    #1265562

    Hi Ismael,

    Thanks for your reply.
    Be sure that I consider all advice that you or your team can give to me, and I will quickly take a look to my layout on small screens ;-)
    Thanks a lot!

    I’m sorry, but you didn’t answered to the first part of my previous post:

    I tried your corrected function and it seems to work on screens from 768px, but it doesn’t work on smaller screens and I need it on smaller screens only.
    Could you please tell me what’s wrong?

    #1266197

    Hi,

    Have you tried to adjust the scroll_offset even more? Currently, the snippet above adds 48px to the default offset value.

    $header['header_scroll_offset'] = $header['header_scroll_offset'] + 48;
    

    Try to adjust the value from 48 to a higher integer.

    Best regards,
    Ismael

    #1266337

    Hi Ismael,
    Thanks for your reply.
    I already tried this.
    To show you, I made a video that you can find in private content.
    I replaced 48 to 348 and as I told you before, you can see it works and it makes a change on desktop screen, but it is not on smaller screens…

    #1266344

    Ok, I made more tests and one more video in private content.
    In fact, as you can see, it seems to work on desktop and mobile, but not on tablet.
    But now I changed layout on tablet without sticky header, I don’t need offset anymore.
    I only need it on mobile.
    So could you please tell me how to define a screen size in your last snippet to make it work for this size only?
    Thanks a lot!

    #1266811

    Hi,

    Thank you for the screencast.

    Did you set the header to be sticky on mobile view? Try to edit the js > avia.js file and remove this code around line 650.

    	if (isMobile) {
    						fixedMainPadding = 0;
    					}
    
    

    Please do not forget to toggle or to temporarily disable the Performance > File Compression settings after doing the modification.

    Best regards,
    Ismael

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