-
AuthorPosts
-
March 21, 2022 at 11:59 pm #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-1338429I 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
UeliMarch 22, 2022 at 6:03 am #1345460Hey 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,
IsmaelMarch 24, 2022 at 12:54 am #1345776Hi 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
UeliMarch 24, 2022 at 3:24 am #1345797Hi!
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,
IsmaelMarch 25, 2022 at 3:18 pm #1346014Hi 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
UeliApril 4, 2022 at 8:21 am #1347097Hi,
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,
IsmaelApril 9, 2022 at 11:39 am #1347775Hi 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
UeliApril 13, 2022 at 4:58 am #1348172Hi,
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,
IsmaelApril 15, 2022 at 8:34 pm #1348523Hi 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
UeliApril 18, 2022 at 5:13 am #1348666Hi,
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,
IsmaelMay 7, 2022 at 8:50 pm #1350896Hi 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
UeliMay 7, 2022 at 9:09 pm #1350898Hi,
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 -
AuthorPosts
- The topic ‘Toggles of accordions are covered by the sticky header’ is closed to new replies.