Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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?

    #1475949

    Hey 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,
    Ismael

    #1475983

    I’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.

    #1475993

    Hi,

    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,
    Ismael

    #1476044
    This reply has been marked as private.
    #1476059

    Hi,

    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,
    Ismael

    #1476338

    Thank 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.
    #1476384

    Hi,

    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,
    Ismael

    #1476445
    This reply has been marked as private.
    #1476497

    Hi,

    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,
    Ismael

    #1476640

    Sure – I’ll include an IP in the private content below. I’ve also set up a staging site.

    #1476803

    Hi,

    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,
    Ismael

    #1476835

    That 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?

    #1476869

    Hi,

    Yes, you can delete the tab_section.js file. Let us know if you have more questions.

    Best regards,
    Ismael

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