Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1345426

    Dear Enfold Support

    As suggested by Enfold’s support member Ismael, I open this separate topic about the issue I mentioned firstly on another thread: https://kriesi.at/support/topic/accordion-toggles-deeplinking/#post-1327294

    I have an accordion with the toggle’s mode “one toggle open at a time”. If I open the first toggle of an accordion on bigger screens (desktop view) and scroll down to the second toggle and open it, the first toggle closes and the document scrolls to the top of the second toggle but the toggle is covered by the sticky header. This always happens if you click from toggle to toggle. On small screens (mobile view) the open toggle is always visible on the top of the page as expected because the header isn’t sticky. I made a short screen video (see link in Private Content) that shows what I mean.

    Ismael has provided the following code for the child theme’s functions.php to control the scroll offset:

    function avf_header_setting_filter_mod($header) {
            if(!wp_is_mobile()) {
    	    $header['header_scroll_offset'] = $header['header_scroll_offset'] - 100;
            }
    	return $header;
    }
    add_filter('avf_header_setting_filter', 'avf_header_setting_filter_mod', 9999, 1);

    Ismael also specified his solution as follows:

    The theme actually ignores the main container’s offset on mobile view, so the filter above will not work. You will also have to edit the themes/enfold/js/avia.js file as instructed in this older thread.
    https://kriesi.at/support/topic/scroll-postion-one-page-mobile/#post-1338429

    I followed Ismael’s instructions but they haven’t the expected impact yet. On desktop browsers, the sticky header still covers the toggles of the accordion.

    I found out that Ismael’s PHP function might not be reloaded or reinitialized properly if you click from toggle to toggle within the same browser window/tab. It only seems to work properly if you copy the URL of a toggle in the address bar of a new browser window/tab. Then the toggle is at the defined scroll-offset position (according to the PHP function) below the sticky header.

    I really appreciate if you could provide a reliable solution very soon.
    Please see site details in Private Content.

    Kind regards
    Ueli

    #1345460

    Hey Ueli,

    Thank you for opening a new thread and for the clarification.

    To fix the issue with the toggles and make sure that the toggle title is visible on click, we edited the enfold/config-templatebuilder/avia-shortcodes/toggles/toggles.js file around line 47 and adjusted the scoll_target value.

     //check if toggle title is in viewport. if not scroll up
    				    var el_offset = content.offset().top,
    				        scoll_target = el_offset - 50 - parseInt($('html').css('margin-top'),10);
    
    				    if(win.scrollTop() > el_offset)
    				    {
    				        $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target - 100},200);
    				    }
    

    We decrease the scoll_target by a 100px in this line.

      $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target - 100},200);
    

    This is where the document scrolls after the modification.

    Screenshot: https://1drv.ms/u/s!AjjTfXSRbKTvwErLVZRV0yQ3_poa?e=1cHiGh

    Please make sure to purge the cache before testing the page, or check the site on incognito mode.

    Best regards,
    Ismael

    #1345776

    Hi Ismael

    Thanks for your new approach but it’s still not really working reliably. If I click from toggle to toggle, sometimes the toggle is below the sticky header but sometimes it’s still covered. I tested on incognito mode with the latest Firefox and Chrome desktop browsers on Windows 10. Interestingly, the two browsers do not behave identically. That means the same toggle can be covered in Firefox whereas it’s visible on Chrome and vice versa. It becomes even stranger if I repeat the test several times. Toggles that have been visible are covered now. At least, it seems to work on the Safari browser with iPadOS.

    I made two screen videos with Firefox and Chrome. Please see links in Private Content.

    Kind regards
    Ueli

    #1345797

    Hi!

    Thank you for testing the changes.

    What happens when you remove the condition or check in this code?

      if(win.scrollTop() > el_offset)
    				    {
    				        $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target - 100},200);
    				    }
    

    Just replace the whole code with this line to make sure that the document scrolls to the target when you click a toggle.

     $('html:not(:animated),body:not(:animated)').animate({scrollTop: scoll_target - 100},200);
    

    Please make sure to purge the cache and disable the Enfold > Performance > File Compression settings before testing the page.

    Regards,
    Ismael

    #1346014

    Hi Ismael

    Your last suggestion seems to work quiet well! Nevertheless, if I click from toggle to toggle, the offset seems not to be exactly the same every time. Sometimes you can slightly see the above toggle, sometimes not. See the screen video in Private Content where I point with the mouse pointer to the position which I mean. It’s not always the same if I repeat the test or reload the page. It also differs from browser to browser. Why does this happen?

    I must admit that I might be a little picky, but it would be nice if the offset is always pixel accurate, so you can’t see the above toggle. I played a little bit with the offset value but I can’t achieve perfect results.

    Kind regards
    Ueli

    #1347097

    Hi,

    Sometimes you can slightly see the above toggle, sometimes not.

    We can reproduce this occasionally but we are not sure what is causing it. It is barely noticeable though and the toggle title is perfectly visible on click. It only happens maybe once every 10 clicks.

    Best regards,
    Ismael

    #1347775

    Hi Ismael

    OK, I can live with that.

    Your latest code causes another thing. The offset is now the same on desktop and mobile view. Is it possible to have a different offset value on mobile view when the header isn’t sticky?

    I’ve also found out, after updating to the latest Enfold Version, that the changes in the enfold/config-templatebuilder/avia-shortcodes/toggles/toggles.js file were overwritten by the update. Is it possible to integrate that JS file with the changes in my Child Theme directory, so I don’t have to alter the file after every Enfold update? Nevertheless, how do I know if there are important changes in that JS file within an Enfold update? It’s a dilemma if that file is integrated in my Child Theme because important updates won’t be effective. In my opinion, that issue with the sticky header covering toggles should be fixed within the original Theme code. I can’t believe that I am the only costumer struggling with that.

    Kind regards
    Ueli

    #1348172

    Hi,

    You can override an existing element in your child theme by creating a new shortcode path in the child theme directory. Please check this documentation.

    // https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb

    Once you have a copy of the toggles shortcode files (js, php) in the shortcodes folder within the child theme directory, you have to update the script path in the extra_assets function in the toggles.php file. Look for this code around line 115.

    function extra_assets()
    		{
    			//load css
    			wp_enqueue_style( 'avia-module-toggles', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/toggles/toggles.css', array( 'avia-layout' ), false );
    
    				//load js
    			wp_enqueue_script( 'avia-module-toggles', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/toggles/toggles.js', array( 'avia-shortcodes' ), false, true );
    		}
    

    Best regards,
    Ismael

    #1348523

    Hi Ismael

    I’m not sure if I understand you right.

    According to the documentation on https://kriesi.at/documentation/enfold/intro-to-layout-builder/#add-elements-to-alb I’ve added to my Child Theme the specific function to the functions.php and the new folder shortcodes with the subfolder toggles and the two files toggles.js and toggles.php.

    The documentation says that If you copy an element from enfold>config-templatebuilder>avia-shortcodes to the folder shortcodes it will replace the one in the parent and be used instead. Since the crucial changes are in toggles.js, why do I have to edit toggles.php as well? And what do you mean with you have to update the script path in toggles.php? Do you mean the part avia-schortcodes/toggles/toggles/toggles.js because in my Child Theme the folder is called shortcodes instead of avia-shortcodes? And what is with the path of the CSS file since I haven’t copied it to my Child Theme? Do I still have to replace avia-shortcodes with shortcodes there?

    And please answer my first question from my last post:

    Your latest code causes another thing. The offset is now the same on desktop and mobile view. Is it possible to have a different offset value on mobile view when the header isn’t sticky?

    Kind regards
    Ueli

    #1348666

    Hi,

    Since the crucial changes are in toggles.js, why do I have to edit toggles.php as well?

    Because you have to tell the shortcode to load the modified js file in the child theme directory instead of the original script. You can only do that by editing the extra_assets function in the toggles.php file as previously mentioned. You can find an example of the path modification here.

    // https://kriesi.at/support/topic/standard-setting-for-video-element/#post-1344649

    As you may notice, the AviaBuilder::$path[‘pluginUrlRoot’] is replaced with get_stylesheet_directory_uri() function to retrieve the child theme folder and the path avia-shortcodes is replaced with shortcodes because that is the name of the new folder in the child theme directory.

    If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

    Thanks!

    Best regards,
    Ismael

    #1350896

    Hi Ismael

    Thanks for your clarification. The modified JS file is now loaded correctly from my Child Theme directory.

    I will open a new thread for my additional question even though I see it as a part of this topic because it is caused by the solution you have provided.

    Kind regards
    Ueli

    #1350898

    Hi,
    Glad Ismael could help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Toggles of accordions are covered by the sticky header’ is closed to new replies.