简体   繁体   中英

Barba.js triggering transition on anchor links

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.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM