Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1103946

    Hi guys

    I am struggling with the following:
    There is an accordion element on the website which works nice and easy (if I use the accordion toggles itself to open/close them).

    In addition to that, there is the site navigation in the right column (see example below).
    So if I use that navigation on the right to open the same toggle in the middle with the same link, the browser always scrolls to that position. This is not the case if I open/close the accordion directly in the middle, but with the same links.

    How do I get rid of the random scroll behaviour?

    Thanks in advance
    Michael

    EDIT:
    Just tried the following jQuery inside functions.php – probably the wrong code:

    <script> 
    $(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();
    
    	$('html, body').animate({
            scrollTop: $($.attr(this, 'href')).offset().top
        }, 1400);
    })(jQuery);	
    </script>
    #1105319

    Hey Michael,

    Thank you for using Enfold.

    That is the scrollspy script for the main menu items. It’s in the js > avia.js file.

     //scrollspy for main menu. must be located before smoothscrolling
    		if($.fn.avia_scrollspy)
    		{
    			if(container == 'body')
    			{
    				$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
    			}
    			else
    			{
    				$('body').avia_scrollspy('refresh');
    			}
    		}

    You can disable that script but it will also affect the smooth scroll option.

    Best regards,
    Ismael

    #1105362

    Hey Ismael

    Thank you very much for your reply – I appreciate it.

    I commented that part of the file avia.js out, but unfortunately this does not do anything.
    I located the file inside my child theme in js -> avia.js but as I said, it is still scrolling like before.

    What am I missing? Pretty sure it is not caching.

    Best regards
    Michael

    #1105365

    Ah – it was caching, sorry.

    So I guess disabling that is not an option either, because then the viewport obviously just stays where it is and always scrolling to the top instead is not possible, right?
    In this case the whole content in the middle would become visible again.

    #1106529

    Hi,

    I think it will still work, but the smooth scrolling animation or effect for the anchors will be removed.

    Best regards,
    Ismael

    #1107727

    Thanks Ismael – you can close this thread please.

    #1107819

    Hi,

    Thanks for the update, I’ll close this thread for now then. Please open a new thread if you should have any further questions or problems.

    Best regards,
    Rikard

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Accordion same link but different behaviour’ is closed to new replies.