Comments (8)
Hi @htor ,
thanks for the very detailed issue.
I think your issue is that fadeOut
do not return a promise, so fadeIn
is called immediately newContainerLoading
is resolved.
You should rewrite your fadeOut
as:
fadeOut: function() {
$(this.oldContainer).toggleClass('fade-out');
return new Promise(function(resolve, reject) {
window.setTimeout(function() {
resolve();
}, 700);
});
},
The best way would be to use the event onanimationend
instead of a simple timeout.
I haven't tried but in this way everything should work, let me know :)
from barba.
Thanks a lot,
Got it to work now, by returning a promise, plus fixing my CSS. Had a comma after the from
clause plus I needed to override the fade-in
animation when the container has both animation classes set on it during the transition. Just hacked it with !important
. Seems to work:
.fade-out { animation: fade-out .5s ease forwards !important; }
.fade-in { animation: fade-in .5s ease forwards; }
@keyframes fade-out {
from { opacity: 1; } /* no comma here */
to { opacity: 0; }
}
@keyframes fade-in {
from { opacity: 0; } /* no comma here */
to { opacity: 1; }
}
Fade-out function:
fadeOut: function() {
$(this.oldContainer).toggleClass('fade-out');
return new Promise(function(resolve, reject) {
window.setTimeout(function() {
resolve();
}, 700);
});
},
from barba.
Nice @htor .
I totally forgot to mention this "extension" made by @JoeeGrigg https://github.com/JoeeGrigg/barba-transitions
from barba.
@luruke that looks promising. By the way I published my barba test app here: https://github.com/htor/pjax-barba-test/
from barba.
Hi guys, thanks for the help. I've followed these tips and was wondering if it's possible to remove the fadein class once it's finished? For example, fadein class is added, then fadeout is added and requires higher specificity in css to override. Can something like this be done?
fadeIn: function() {
this.newContainer.classList.add('animate-fade-in');
this.done();
this.addEventListener('animationend', function(e) {
this.newContainer.classList.remove('animate-fade-in');
}, false);
}
from barba.
The best way would be to use the event onanimationend instead of a simple timeout.
Could you please provide an example of the onanimationend event?
I have tried the following, it works the first time, but on the second click I get "Uncaught TypeError: Cannot read property 'removeChild' of null".
this.newContainer.addEventListener('animationend', function(e) {
_this.done();
}
Any ideas?
from barba.
I have tried the following, it works the first time, but on the second click I get "Uncaught TypeError: Cannot read property 'removeChild' of null".
For anyone stumbling across this, I had to REMOVE the event listener after I added it otherwise it would try to call twice.
newContainer.addEventListener("animationend",function handler() {
_this.done();
newContainer.removeEventListener("animationend",handler);
newContainer.classList.remove('animate-fade-in');
newContainer.removeAttribute("style");
});
from barba.
Hi guys, thanks for the help. I've followed these tips and was wondering if it's possible to remove the fadein class once it's finished? For example, fadein class is added, then fadeout is added and requires higher specificity in css to override. Can something like this be done?
fadeIn: function() { this.newContainer.classList.add('animate-fade-in'); this.done(); this.addEventListener('animationend', function(e) { this.newContainer.classList.remove('animate-fade-in'); }, false); }
Did you find how to do this? im having the same problem.
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.