
-
AuthorPosts
-
January 28, 2025 at 8:34 pm #1475942
I have a large tab element with tabs on the right side. I’d like to disable the behavior that scrolls you up to the top of the tabs on click. The hash appears and the browser window goes back up to the top. This would normally be fine but I’ve added some js that auto-cycles through the tabs and I don’t want the user pulled back up if they’ve scrolled past the element. Any help in disabling this?
January 29, 2025 at 4:55 am #1475949Hey jmoriart,
Thank you for the inquiry.
This is possible, but you will need to override the default toggle script. Add this code to the functions.php file:
function av_override_avia_scripts() { wp_dequeue_script('avia-module-toggles'); wp_deregister_script('avia-module-toggles'); $child_toggles_js = get_stylesheet_directory_uri() . '/js/toggles.js'; wp_enqueue_script( 'avia-module-toggles', $child_toggles_js, array('avia-shortcodes'), false, true ); } add_action('wp_enqueue_scripts', 'av_override_avia_scripts', 100);
After that, create a copy of the enfold/config-templatebuilder/avia-shortcodes/toggles/toggles.js file and place it in the child theme > js folder. Edit the file, then remove all instances of the scroll_to_viewport function.
Let us know of the result.
Best regards,
IsmaelJanuary 29, 2025 at 9:17 pm #1475983I’ve done that and I’m not seeing any change.
Page is https://new.shadehaven.net/mobile-shade-for-animals/
I have some custom code that is autoplaying videos and then the next tab is clicked (via js) when the video completes. If you are scrolled past the tab element you’ll be pulled back up to the top when the hash changes. Alternatively just clicking on the tab manually has the same effect.January 30, 2025 at 6:26 am #1475993Hi,
Thank you for the update.
Have you tried to temporarily disable the Enfold > Performance > File Compression settings? Make sure to purge the cache afterward. If it’s still not working, provide the login details in the private field so that can further check the issue.
Best regards,
IsmaelJanuary 30, 2025 at 10:33 pm #1476044This reply has been marked as private.January 31, 2025 at 7:25 am #1476059Hi,
Sorry for the confusion. I thought you’re working on an Accordion element. For the Tab Section element, please override the enfold/config-templatebuilder/avia-shortcodes/tab_section/tab_section.js file, look for the get_init_open function and replace it with:
get_init_open = function() { var hash = window.location.hash ? window.location.hash : '', deepHash = hash.toLowerCase().replace('#', ''), open = null; if ('undefined' != typeof(deepLinksToTabs[deepHash]) && '' != deepLinksToTabs[deepHash]) { var hashID = deepLinksToTabs[deepHash]; open = tabs.filter('[data-av-tab-section-title="' + hashID + '"]'); } else { open = tabs.filter('[href="' + hash + '"]'); } if (open.length) { if (!open.is('.active_tab')) { open.trigger('click'); var tabOffset = open.offset().top; var currentScroll = $(window).scrollTop(); $(window).scrollTop(currentScroll); } } else { // set correct color container.find('.av-active-tab-title').trigger('click', true); } };
You will also have to replace the filter in the functions.php file:
function av_override_avia_scripts() { wp_dequeue_script('avia-module-tabsection'); wp_deregister_script('avia-module-tabsection'); $child_tab_section_js = get_stylesheet_directory_uri() . '/js/tab_section.js'; wp_enqueue_script( 'avia-module-tabsection', $child_tab_section_js, array('avia-shortcodes'), false, true ); } add_action('wp_enqueue_scripts', 'av_override_avia_scripts', 100);
Best regards,
IsmaelFebruary 4, 2025 at 6:05 pm #1476338Thank you. So unfortunately I’m still seeing that same behavior. I put the edited tab_section.js file in my own child theme /js directory and then updated that override function in functions.php. Cleared caches. No change.
-
This reply was modified 3 weeks, 3 days ago by
jmoriart.
February 5, 2025 at 5:12 am #1476384Hi,
Thank you for the update.
We may need to access the server via FTP to test the modifications further. Please provide the login details in the private field.
Best regards,
IsmaelFebruary 5, 2025 at 7:54 pm #1476445This reply has been marked as private.February 6, 2025 at 10:00 am #1476497Hi,
Thank you for the info.
We can’t access the server using the credentials provided. Are you sure they are correct? Please create a staging site and provide the WP and FTP details in the private field.
Best regards,
IsmaelFebruary 7, 2025 at 4:16 pm #1476640Sure – I’ll include an IP in the private content below. I’ve also set up a staging site.
February 10, 2025 at 7:24 am #1476803Hi,
Again, sorry for the confusion. We have overridden the config-templatebuilder/avia-shortcodes/tabs/tabs.js file and removed lines 133 and 161. Please check the staging site and clear the cache.
Best regards,
IsmaelFebruary 10, 2025 at 4:44 pm #1476835That seems to be working. So can I get rid of my child-theme copy of tab_section.js then? Or is that necessary as well as tab.js?
February 11, 2025 at 4:50 am #1476869 -
This reply was modified 3 weeks, 3 days ago by
-
AuthorPosts
- You must be logged in to reply to this topic.