Barba.js triggering transition on anchor links

1.2k Views Asked by At

quite noob user of Barba.js here.

I am using Barba.js on a Joomla website, and almost everything is working fine.

My problem is that Barba.js is triggering the page transition also on my anchor links, and it redirects to the homepage.

<a href="#section3">Click here</a>

This is the element that I have on my mydomain.com/index.php/secondPage

When I click on the element, the site barba-transitions to mydomain.com/index.php#section3

But if I go to my secondPage and refresh the page, the anchor link works perfectly.

What am I missing?

Thank you very much.

1

There are 1 best solutions below

0
Szymon Jankowski On

If you don't want certain links to be processed by Barba.js you can add a class to them - so the Barba knows it's not Barba business. For example - add prevent-barba class and then in Barba init function parameters add:

prevent: ({ el }) => el.classList && el.classList.contains('prevent-barba'),

Hope that helps :)