Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1465689

    Hello,
    I have several links pointing to individual tabs of the tab section, but the page doesn’t scroll to the position of the tab section.
    Thanks for your help!

    #1465755

    Hey Leeonella,

    Thank you for the inquiry.

    We may need to inspect the site in order to properly check the issue. Please provide the login details in the private field. In the meantime, you can try this script in the functions.php file:

    // script to scroll to the active tab section
    function ava_custom_script_tab_section_scroll() {
        ?>
        <script type="text/javascript">
        (function($) {
            function avTriggerScrollToTab(selector, event) {
                $(selector).on(event, function() {
                    var isLoadEvent = event === 'load';
                    var locationHash = isLoadEvent ? window.location.hash : $(this).attr('href');
                    var hash = isLoadEvent ? locationHash : locationHash.substring(locationHash.indexOf('#'));
                    var tab = $('.av-section-tab-title[href="' + hash + '"]');
                    var parentContainer = tab.closest('.av-tab-section-outer-container');
                    
                    if (tab.length && parentContainer.length) {
                        var position = parentContainer.offset().top;
                        tab.trigger('click');
    
                        if (hash) {
                            setTimeout(function() {
                                $('html, body').animate({ scrollTop: position - 100 }, 500);
                            }, 300);
                        }
                    }
                });
            }
    
            $(document).ready(function() {
                var tabs = $('.av-tab-section-container');
                if (tabs.length === 0) return;
    
                avTriggerScrollToTab('.menu-item a', 'click');
                avTriggerScrollToTab(window, 'load');
            });
        })(jQuery);
        </script>
        <?php
    }
    add_action('wp_footer', 'ava_custom_script_tab_section_scroll', 9999);
    

    Best regards,
    Ismael

    #1465799

    Hi Ismael,
    thank you very much, it’s working now!
    I only had to adapt the line of code
    avTriggerScrollToTab('.menu-item a', 'click');
    with the corresponding CSS class

    #1465809

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic, or if we can close it.

    Best regards,
    Rikard

    #1465821

    Thank you, please close it.

    #1465872

    Hi,

    Thanks for letting us know. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Linking to tab section not working’ is closed to new replies.