Comments (13)
Hello @na86!
Thank you for trying Barba.js
I've used barba with WordPress in few project and there are no problems with it.
From the error I can assume you are trying to load a page that doesn't contain .barba-container
. (Or another class if you changed it)
Are you sure yours template are using the correct Dom structure?
Are you logged as admin in WordPress and clicking (or hovering if the prefetch is active) on the admin bar?
Usually I disable barba.js when the user is logged as administrator in order to avoid this problems.
from barba.
I changed the title to be more appropriate
from barba.
Thank you Luigi,
it works!!!
(i'm used to develop wordpress site in the ordinary way, this is a kind of adventure for me.)
p.s.: sorry for the title, thankyou for replacing it.
from barba.
Hi Nan, do you have any tips for adding this to Wordpress?
Thanks
from barba.
Hi @paulzz3000 , do you have any specific problem?
Usually for the DOM structure, in the header file I add something like:
<head>...</head>
<body>
<main id="barba-wrapper">
<div data-namespace="<?php echo get_current_template() ?>" <?php body_class('barba-container') ?>
where get_template_file() is something like
function get_current_template() {
global $template;
return basename($template, '.php');
}
and then in the footer I just close my barba-container and barba-wrapper.
from barba.
Thanks @luruke for your answer!
from barba.
This is awesome @luruke - and works great with Wordpress (almost to easy). I run into an issue though with using the wordpress menu outside of the barba-wrapper, the active state on links does not get updated accordingly. I'm using a css navwalker function in functions.php to update the active state on each link after it gets clicked, but this function only gets called once if it is outside of the barba wrapper, any ideas regarding this, is it safe to call a php function with javascript? Or would that even be the right direction to go in? Thanks!
from barba.
Hi @dblodorn .
You can:
- Get all the HTML of the new page, and detect which is the active link, then via js update accordingly: #49
- Add a data parameter on the
.barba-container
with the current menu id, then via js update accordingly reading the data attributenewPageReady
event
from barba.
If I want not all pages to be without reboot, how can I do this? Now, when I turn to a page without a container, does it give me this error (Uncaught (in promise) Error: Barba.js: no container found.....) ???
from barba.
@KushnerMikalai ,
ideally all the pages of your website should use barba-container
.
If you can't, you should add a check with initStateChange
and force the page reload to the newer URL that do not have barba-container
from barba.
Please provide a code example...
from barba.
Hi @luruke I like this plugin! too bad for me I just discovered it. I'd like to ask, have you tried this to a wodpress page builder? (which they tend to throw classes on body tag to work). If you do, can you share your experience....
from barba.
I know this is an old thread; just wanted to let you know (for the sake of others maybe) I ran into the same problem and fixed it by using the enqueue script for the footer instead.
The issue is has a simple cause: BarbaJS doesn't know the container exists because at that point, it doesn't (before DOM load).
tl;dr; set the last parameter in your enqueue_script function (where barba functions are loaded) to true.
https://developer.wordpress.org/reference/functions/wp_enqueue_script/
from barba.
Related Issues (20)
- Limit the number of prefetched links
- THREEJS meshes disappearing after barba transition HOT 1
- Barba.JS not work with GSAP Line Animation HOT 1
- Add setting to cache rendered HTML
- Footer overlapping issue on the documentation website HOT 2
- Improve documentation for WordPress HOT 2
- How to add/initialize other JS files after the page transition which is built with barba & gsap? HOT 2
- How to create transition sliding up card? HOT 1
- `RangeError` on manual hash change
- How to check for barbacontainer HOT 1
- Safari flash the leaving container HOT 6
- Add support for multiple `namespace` in `Views`
- Improve `next.container` availability
- About `View` transitions API HOT 3
- POST Form transition HOT 1
- Source map failed to load HOT 3
- Compiling error HOT 1
- Disable `prefetch` on specific links HOT 1
- Maintain element on transition HOT 1
- Typescript issue with documentation example HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from barba.