-
AuthorPosts
-
May 24, 2019 at 4:23 pm #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
MichaelEDIT:
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>
May 30, 2019 at 3:43 am #1105319Hey 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,
IsmaelMay 30, 2019 at 7:00 am #1105362Hey 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
MichaelMay 30, 2019 at 7:05 am #1105365Ah – 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.June 3, 2019 at 3:14 am #1106529Hi,
I think it will still work, but the smooth scrolling animation or effect for the anchors will be removed.
Best regards,
IsmaelJune 5, 2019 at 7:42 pm #1107727Thanks Ismael – you can close this thread please.
June 6, 2019 at 6:13 am #1107819 -
AuthorPosts
- The topic ‘Accordion same link but different behaviour’ is closed to new replies.